Start New Discussion within our Software Development Community

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
This article has been dead for over six months. Start a new discussion instead.