|
-
Jun 22nd, 2000, 05:51 PM
#1
Thread Starter
New Member
I am trying to write a function for VB 6 which returns an array of every directory in a path. I know that this involves recursive coding, but everything I try returns in error messages and a load of crap.
Anybody who can help me with this, please could you e-mail me @ [email protected]
Many thanks.
-
Jun 22nd, 2000, 06:04 PM
#2
Lively Member
Hi,
try the code below. It receives a listbox and the startpath as parameters and fills all the subdirs beginning with startpath in the listbox.
Good Luck!
Roger
Sub readdir(fillinlist As ListBox, startpath)
On Error Resume Next
Dim found As String
Dim paths() As String
Dim pathcount As Long
Dim i As Long
startpath = Trim$(startpath)
If Right$(startpath, 1) <> "\" Then startpath = startpath & "\"
found = Dir(startpath & "*.*")
Do While Len(found) > 0
fillinlist.AddItem startpath & found
found = Dir
Loop
pathcount = 0
found = Dir(startpath, vbDirectory)
Do While Len(found) > 0
If found <> "." And found <> ".." Then
pathcount = pathcount + 1
If pathcount = 1 Then
ReDim paths(1 To 1)
Else
ReDim Preserve paths(1 To pathcount)
End If
paths(pathcount) = startpath & found
End If
found = Dir
Loop
For i = 1 To pathcount
readdir fillinlist, paths(i)
Next
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|