Guest User

Untitled

a guest
Jun 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.  
  3. TreeView1.Nodes.Clear()
  4.  
  5. Dim Path As String = My.Application.Info.DirectoryPath & "\Projects\"
  6.  
  7. TreeView1.Nodes.Add(Path.ToString, Path)
  8. GetFilesnFolders(Path.ToString, TreeView1.Nodes(Path))
  9. Dim a As String() = TreeView1.TopNode.Text.Split("\".ToCharArray)
  10. TreeView1.TopNode.Text = a(a.Length - 1).ToString.ToUpper
  11.  
  12. TreeView1.Nodes.Item(0).Expand()
  13.  
  14. End Sub
  15.  
  16. Public Sub GetFilesnFolders(ByVal FolderName As String, ByVal RefNode As TreeNode)
  17.  
  18. Dim FolderList As Array = Directory.GetDirectories(FolderName.ToString)
  19. Dim FileListofRoot As Array = Directory.GetFiles(FolderName.ToString)
  20.  
  21. For int As Integer = 0 To FileListofRoot.Length - 1
  22. Dim RootFile As New TreeNode(FileListofRoot(int).ToString)
  23. RefNode.Nodes.Add(RootFile)
  24. Next
  25.  
  26. For i As Integer = 0 To FolderList.Length - 1
  27. Dim TempNode As New TreeNode(FolderList(i).ToString.ToUpper)
  28. RefNode.Nodes.Add(TempNode)
  29. Dim FileList As Array = Directory.GetFiles(FolderList(i).ToString)
  30. GetFilesnFolders(FolderList(i), TempNode)
  31. Next
  32.  
  33. End Sub
Add Comment
Please, Sign In to add comment