Display directory and its all sub directories in treeview in vb.net

 

Display directory and its all sub directories in treeview in vb.net

Private Sub Button1_Click(ByVal sender As System.Object,
                              ByVal e As System.EventArgs) Handles Button1.Click
        Processtree("D:")
End Sub
 
Sub Processtree(ByVal dirPath As String)
 
        Treeview1.BeginUpdate()
        Treeview1.Nodes.Add(New TreeNode(dirPath))
        Treeview1.EndUpdate()
        Treeview1.Refresh()
        Dim objDirInfo As New DirectoryInfo(dirPath)
        Dim objSubDirInfo As DirectoryInfo() = objDirInfo.GetDirectories("*.*")
        Dim Directoryname As DirectoryInfo
        For Each Directoryname In objSubDirInfo
            Try
                Processtree(Directoryname.FullName)
            Catch ex As Exception
 
            End Try
        Next
End Sub

2 thoughts on “Display directory and its all sub directories in treeview in vb.net”

  1. I’m not sure where you’re getting your information, but good topic. I needs to spend some time learning much more or understanding more. Thanks for the above code

Comments are closed.