|
-
Oct 3rd, 2002, 04:14 AM
#1
Thread Starter
Hyperactive Member
Search a directory for a file including sub direcotries
How do I search a directory for a file and have it search SUB dir's also? i.e searching the Directory C:\ and being able to find my file.txt which is a few levels down.
C:\
C:\new folder 1\
C:\new folder 1\new folder 2\
C:\new folder 1\new folder 2\my file.txt
-------------------------------------------------
My code - doesn't work sadly....
Dim objFSO As New FileSystemObject
Dim objFile As File
Dim objFolder As Folder
Dim objsubfolder As Folders
Set objFolder = objFSO.GetFolder(DirList.List(DirList.ListIndex))
' Loop through each sub directory.
For Each objsubfolder In objFolder.SubFolders
' Loop through each file in the sub directory.
For Each objFile In objFolder.Files
Debug.Print objFile.Name
Next objFile
Next objsubfolder
----------------------------------
Any ideas? Thanks!
- Gabe
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
|