The child nodes are there when first populated but when drives are changed or re loaded a second time, that is when they are missing, so how do I reset the nodes to show child nodes every time
This is my code, can anybody see a problem, any help much appreciated
thistreeview.nodes.clear
Dim basenode As System.Windows.Forms.TreeNode
If IO.Directory.Exists(path) Then
If path.Length <= 3 Then
basenode = ThisTreeview.Nodes.Add(path)
Else
basenode = ThisTreeview.Nodes.Add(My.Computer.FileSystem.GetName(path))
End If
basenode.Tag = path
Treeview_LoadDir(path, basenode)
Else
Throw New System.IO.DirectoryNotFoundException()
End If
ThisTreeview.Sort()
ThisTreeview.TopNode.Expand()
Public Sub Treeview_LoadDir(ByVal DirPath As String, ByVal Node As Windows.Forms.TreeNode)
On Error Resume Next
Dim Dir As String
Dim Index As Integer
If Node.Nodes.Count = 0 Then
For Each Dir In My.Computer.FileSystem.GetDirectories(DirPath)
Index = Dir.LastIndexOf("\")
Node.Nodes.Add(Dir.Substring(Index + 1, Dir.Length - Index - 1))
Node.LastNode.Tag = Dir
Node.LastNode.ImageIndex = 0
Next
End If