Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scanning directories and subdirectories??

Status
Not open for further replies.

gicio

Programmer
Jun 18, 2002
39
DE
Is it possible to scan all directories AND subdirectories beginning from a specified path and save the directoriesnames in a Collection?
The "Dir"-method work fine for directories without subdirectories, but if there are subdirectories the "Dir"-method quit wit the error "Invalid procedure or argument) if it steps back to a parent-directory.


gicio
 
You could always use the FileSystemObject.
This code works like a champ :
(remember to include the ScriptingRunTime in your project)


Dim oFSO As Scripting.FileSystemObject

Private Sub Form_Load()
Set oFSO = New Scripting.FileSystemObject
iterate "c:\3pm"
End Sub

Private Function iterate(ByVal sDir As String) As String
Dim oDir As Scripting.Folder
Dim oSDir As Scripting.Folder

Set oDir = oFSO.GetFolder(sDir)

For Each oSDir In oDir.SubFolders
Debug.Print oSDir.Path
iterate oSDir.Path
Next
End Function



Let me know if that helps,
-Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top