Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- TreeView1.Nodes.Clear()
- Dim Path As String = My.Application.Info.DirectoryPath & "\Projects\"
- TreeView1.Nodes.Add(Path.ToString, Path)
- GetFilesnFolders(Path.ToString, TreeView1.Nodes(Path))
- Dim a As String() = TreeView1.TopNode.Text.Split("\".ToCharArray)
- TreeView1.TopNode.Text = a(a.Length - 1).ToString.ToUpper
- TreeView1.Nodes.Item(0).Expand()
- End Sub
- Public Sub GetFilesnFolders(ByVal FolderName As String, ByVal RefNode As TreeNode)
- Dim FolderList As Array = Directory.GetDirectories(FolderName.ToString)
- Dim FileListofRoot As Array = Directory.GetFiles(FolderName.ToString)
- For int As Integer = 0 To FileListofRoot.Length - 1
- Dim RootFile As New TreeNode(FileListofRoot(int).ToString)
- RefNode.Nodes.Add(RootFile)
- Next
- For i As Integer = 0 To FolderList.Length - 1
- Dim TempNode As New TreeNode(FolderList(i).ToString.ToUpper)
- RefNode.Nodes.Add(TempNode)
- Dim FileList As Array = Directory.GetFiles(FolderList(i).ToString)
- GetFilesnFolders(FolderList(i), TempNode)
- Next
- End Sub
Add Comment
Please, Sign In to add comment