Skiping the Not accessible directory
I have written a code for populating the folder structure into tree view. But whenever the folder is not accesible its throwing an error or keeps waiting. I want it to skip that folder and move to next folder. Below is my code
Private Sub BuildDirectoryTree()
Dim newDirectory As TreeNode
Dim justTheSubdirectory As String
Dim basePath as String = "C:\"
For Each oneDirectory As String In My.Computer.FileSystem.GetDirectories(basePath)
justTheSubdirectory = My.Computer.FileSystem.GetName(oneDirectory)
If (fromNode Is Nothing) Then
newDirectory = FrmTreeViewDirectory.Nodes.Add(justTheSubdirectory)
Else
newDirectory = fromNode.Nodes.Add(justTheSubdirectory)
End If
BuildDirectoryTree(newDirectory, My.Computer.FileSystem.CombinePath(basePath, justTheSubdirectory))
Next oneDirectory
End Sub
Can any one modify this and post it back so that it works for the folders that its accessible