I am wanting to display the PC's System Directory in a treeview. I have been searching for how to do this for some time now without finding anything. if anybody can help me out i would greatly appreciate it.
thanks
I am wanting to display the PC's System Directory in a treeview. I have been searching for how to do this for some time now without finding anything. if anybody can help me out i would greatly appreciate it.
thanks
try this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
treeDir.Nodes.Clear()
CreateDirTree(Nothing, Environment.SystemDirectory)
End Sub
Private Sub CreateDirTree(ByVal fromNode As TreeNode, ByVal basePath As String)
Dim newDir As TreeNode
Dim subDir As String
For Each singleDir As String In My.Computer.FileSystem.GetDirectories(basePath)
subDir = My.Computer.FileSystem.GetName(singleDir)
If fromNode Is Nothing Then
newDir = treeDir.Nodes.Add(subDir)
Else
newDir = fromNode.Nodes.Add(subDir)
End If
CreateDirTree(newDir, My.Computer.FileSystem.CombinePath(basePath, subDir))
Next singleDir
End Sub
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.