gladiator83x
Member
- Joined
- Jan 15, 2008
- Messages
- 11
- Programming Experience
- Beginner
Hi All,
I have six directories which all contain files within them. I am trying to make a treeview that will display them in hierarchal form. The directory itself is the root, and the files are the children. I was doing well with displaying the roots (6 directories) but I am running into problems with trying to set the files to be the children nodes. Here is my code:
*---------------------------------------------------------*
Dim dir1 As New IO.DirectoryInfo("1.0 Test Objective")
Dim dir2 As New IO.DirectoryInfo("2.0 Test Setup")
Dim dir3 As New IO.DirectoryInfo("3.0 Test Status")
Dim dir4 As New IO.DirectoryInfo("4.0 Test Methods")
Dim dir5 As New IO.DirectoryInfo("5.0 Test Results")
Dim dir6 As New IO.DirectoryInfo("6.0 Test Planning and Goals")
'---------------SECTION 1.0-----------------
Dim d1 As IO.FileInfo() = dir1.GetFiles()
Dim directory1 As IO.FileInfo
Dim node1 As TreeNode = TreeView1.Nodes.Add(dir1.Name)
node1.Nodes.Add(dir1.Name)
For Each directory1 In d1
node1.Nodes.Add(directory1)
Next
'--------------------------------------------
I do the same thing for the next 5 directories. I think that I need to make node1 an array somehow b/c there's more than one file in that directory. I tried things such as:
Dim node5() As TreeNode = TreeView1.Nodes.Add(dir5.Name)
but I was unsuccessful. Any help would be greatly appreciated. Thanks!
I have six directories which all contain files within them. I am trying to make a treeview that will display them in hierarchal form. The directory itself is the root, and the files are the children. I was doing well with displaying the roots (6 directories) but I am running into problems with trying to set the files to be the children nodes. Here is my code:
*---------------------------------------------------------*
Dim dir1 As New IO.DirectoryInfo("1.0 Test Objective")
Dim dir2 As New IO.DirectoryInfo("2.0 Test Setup")
Dim dir3 As New IO.DirectoryInfo("3.0 Test Status")
Dim dir4 As New IO.DirectoryInfo("4.0 Test Methods")
Dim dir5 As New IO.DirectoryInfo("5.0 Test Results")
Dim dir6 As New IO.DirectoryInfo("6.0 Test Planning and Goals")
'---------------SECTION 1.0-----------------
Dim d1 As IO.FileInfo() = dir1.GetFiles()
Dim directory1 As IO.FileInfo
Dim node1 As TreeNode = TreeView1.Nodes.Add(dir1.Name)
node1.Nodes.Add(dir1.Name)
For Each directory1 In d1
node1.Nodes.Add(directory1)
Next
'--------------------------------------------
I do the same thing for the next 5 directories. I think that I need to make node1 an array somehow b/c there's more than one file in that directory. I tried things such as:
Dim node5() As TreeNode = TreeView1.Nodes.Add(dir5.Name)
but I was unsuccessful. Any help would be greatly appreciated. Thanks!