S
Scott Rymer
I'm currently loading a treeview with a directory tree which excludes user
defined paths:
Private Sub AddFolders(ByVal ParentNode As TreeNode)
'Load the Folders to exclude from the listview
Dim xFolders = From f In
XDocument.Parse(My.Resources.ExludeFolders).Descendants("FolderPath") _
Select f.Value
'Get the folders under the ParentNode
Dim folders = From folder In New
DirectoryInfo(ParentNode.Tag).GetDirectories() _
Where Not xFolders.Contains(folder.FullName) _
Select folder
'Add them to the Directory tree
For Each folder In folders
Dim N = ParentNode.Nodes.Add(folder.Name)
N.Tag = folder.FullName
Next
End Sub
What I would also now like to do is only include folders which contains
specific file types (*.dft) - or exclude ones that don't. I'm trying the
code below but I'm getting warning "Runtime errors might occur when
converting 'System.Collections.Generic.IEnumerable(Of String)' to 'String'"
Dim folders = From folder In New
DirectoryInfo(ParentNode.Tag).GetDirectories() _
Where folder.FullName.Contains(From d In
folder.GetFiles("*.dft", SearchOption.TopDirectoryOnly) Select d.FullName) _
And Not xFolders.Contains(folder.FullName) _
Select folder
Any suggestions?
defined paths:
Private Sub AddFolders(ByVal ParentNode As TreeNode)
'Load the Folders to exclude from the listview
Dim xFolders = From f In
XDocument.Parse(My.Resources.ExludeFolders).Descendants("FolderPath") _
Select f.Value
'Get the folders under the ParentNode
Dim folders = From folder In New
DirectoryInfo(ParentNode.Tag).GetDirectories() _
Where Not xFolders.Contains(folder.FullName) _
Select folder
'Add them to the Directory tree
For Each folder In folders
Dim N = ParentNode.Nodes.Add(folder.Name)
N.Tag = folder.FullName
Next
End Sub
What I would also now like to do is only include folders which contains
specific file types (*.dft) - or exclude ones that don't. I'm trying the
code below but I'm getting warning "Runtime errors might occur when
converting 'System.Collections.Generic.IEnumerable(Of String)' to 'String'"
Dim folders = From folder In New
DirectoryInfo(ParentNode.Tag).GetDirectories() _
Where folder.FullName.Contains(From d In
folder.GetFiles("*.dft", SearchOption.TopDirectoryOnly) Select d.FullName) _
And Not xFolders.Contains(folder.FullName) _
Select folder
Any suggestions?