# VB6.0 Problem



## ags131 (Oct 6, 2007)

I am i need of assistance. I want to get the directory/file data for a folder and put that in a treeview control. I have it where it will find the first directory but not subsequent directories.
Ex.

```
|--Dir
   |--Subdir1
   |  |--Subdir3
   |  |  |--Subdir5
   |  |
   |  |--Subdir4
   |
   |--Subdir2
```
But the only directories shown are:

```
|--Dir
   |--Subdir1
   |  |--Subdir3
   |  |--Subdir4
   |
   |--Subdir2
```
Dir1 is a directory control that is invisible. the purpose of isolateing the folders is to keep useres form browsing the wrong folder. Thus locking the app into a specified dir.

If anyone has better code then feel free to post.


```
Call tree.Nodes.Add(,, , "Main Dir", 1, 2)

dirPth = Dir1.Path
lendirpth = Len(dirPth)
dirCount = Dir1.ListCount
For I = 0 To dirCount - 1
  tmp = Dir1.List(I)
  tmp = VBA.Right$(tmp, (Len(tmp) - lendirpth) - 1)
  Call tree.Nodes.Add(tree.Nodes(1), tvwChild, , tmp, 1, 2)
Next I

For I = 0 To dirCount - 1
  Dir1.Path = Dir1.List(I)
  lenDirPth2 = Len(Dir1.Path)
  For Ii = 0 To Dir1.ListCount - 1
    tmp = Dir1.List(Ii)
    tmp = VBA.Right$(tmp, (Len(tmp) - lenDirPth2 - 1))
    Call tree.Nodes.Add(tree.Nodes(I + 2), tvwChild, , tmp, 1, 2)
  Next Ii
  Dir1.Path = dirPth
Next I
```


----------

