|
Imports <xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim query = From file In My.Computer.FileSystem.GetFiles(txtPath.Text, FileIO.SearchOption.SearchAllSubDirectories) _
Where file.EndsWith(".snippet") _
Order By file
Dim snippets As New List(Of Snippet)
Dim snippetDocument As XElement
Dim snippet As Snippet
For Each item In query
snippetDocument = XElement.Load(item)
If snippetDocument...<Title>.Value IsNot Nothing Then
snippet = New Snippet With {.Title = snippetDocument...<Title>.Value.ToString _
, .Description = snippetDocument...<Description>.Value.ToString _
, .Path = item _
, .Size = New System.IO.FileInfo(item).Length}
snippets.Add(snippet)
End If
Next
DataGridViewSnippets.AutoGenerateColumns = True
DataGridViewSnippets.DataSource = snippets
End Sub
End Class
Public Class Snippet
Private _Title As String
Private _Description As String
Private _Path As String
Private _Size As Long
Public Property Title() As String
Get
Return _Title
End Get
Set(ByVal value As String)
_Title = value
End Set
End Property
Public Property Description() As String
Get
Return _Description
End Get
Set(ByVal value As String)
_Description = value
End Set
End Property
Public Property Path() As String
Get
Return _Path
End Get
Set(ByVal value As String)
_Path = value
End Set
End Property
Public Property Size() As Long
Get
Return _Size
End Get
Set(ByVal value As Long)
_Size = value
End Set
End Property
End Class |