-
Searching Directories
I am searching a directory, my question is how do you search all of the subdirectories thereof?
Here is my code..
Private Sub cmdSearch_Click()
Dim sFile As String
Dim strClientID As String
strClientID = txtClient.Text
sFile = Dir$("C:\DigiSend\3-21\" & strClientID & "*.pdf") 'Get the first file
Do While Len(sFile) > 0 'Loop until we run out of files
lstQueryResults.AddItem sFile 'Add the file
sFile = Dir$ 'Get the next file
Loop
End Sub
Thanks!
-
you should use a recursive function call.
use the vbDirectory attribute in the Dir function, then for each directory call the function. Recursion gets a bit confusing, but this is what its perfect for!
-
The best way is with the FileSystemObject
Sample code here.
-