Hello,
I am trying to create a costom windows explorer with treeview. I can get the drives but I have problems getting all the folders and subfolders. Help please.
vbBoy
Hello,
I am trying to create a costom windows explorer with treeview. I can get the drives but I have problems getting all the folders and subfolders. Help please.
vbBoy
How come? What's the problem?
There's surely a better way, this is too slow:
Dirs is a DirListBox and TV is a TreeView. But as I said... it's way too slowCode:Option Explicit
Private Sub Form_Load()
Dirs.Path = "C:\"
TV.Nodes.Add , , "C:\", "C:\"
AllDirs 0
End Sub
Private Sub AllDirs(Indice As Integer)
If Dirs.ListCount Then
If Dirs.List(Indice) = "" Then Exit Sub
TV.Nodes.Add Dirs.Path, tvwChild, Dirs.List(Indice), _
Mid$(Dirs.List(Indice), RInstr(Dirs.List(Indice), "\") + 1)
Dirs.Path = Dirs.List(Indice)
AllDirs 0
Dirs.Path = Left$(Dirs.Path, RInstr(Dirs.Path, "\") - 1)
AllDirs Indice + 1
End If
End Sub
Private Function RInstr(AllString As String, ToFind As String)
Dim i As Integer
For i = Len(AllString) To 1 Step -1
If Mid$(AllString, i, Len(ToFind)) = ToFind Then Exit For
Next i
RInstr = i
End Function
There is a pretty decent tutorial here on using FSO to populate a Treeview with drives and folders/sub-folders.
http://abstractvb.com/learn.asp?CID=85
Not the fastest way and I'm positive FuzzyBurt will have a comment about using FSO but....
:)
Here is a sample I wrote the first week I got my hands on VB4/32 (note the crappy icons) I commented it pretty good because I posted it on a lot of sites back then. I works good but please don't comment on my code it was a long time ago. In fact, I'm amazed I still have it.
It uses the win32 API and not FSO
Greg
It has helped me a lot.
vbBoy.
How did you change the title of your post to include (Resolved)
Nice idea