Cargar la estructura de arbol del disco en un TreeView
Artículo por Club Developers · 11 mayo 2006
2387 vistas
Veamos cómo cargar el sistema de carpetas del disco C:\ en un TreeView (estilo al Explorador de Windows).
vbnet
Imports System Imports System.IO Imports System.Windows.Forms '... Private Sub Explorer(ByVal node As TreeNode) Try Dim s As String node.Nodes.Clear() For Each s In Directory.GetDirectories(node.FullPath) node.Nodes.Add(Path.GetFileName(s)) Next Catch End Try End Sub Private Sub BTNClick(ByVal sender As Object, ByVal e As EventArgs) TV.Nodes.Add("C:\") Explorer(TV.Nodes.Item(0)) End Sub Private Sub TVAfterExpand(ByVal sender As Object, ByVal e As TreeViewEventArgs) Dim tn As TreeNode For Each tn In e.Node.Nodes Explorer(tn) Next End Sub