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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File System Object??? 2

Status
Not open for further replies.

bakerm

Programmer
Joined
Apr 25, 2000
Messages
53
Location
US
I would like to know how to locate all files of type ".vbp"
that reside in a parent folder, lets say "C: Project FIles".

I need to know how to iterate through the parent folder, >>>and subfolders<<<, using the File System Object. Have had no luck so far.

Any help would be greatly appreciated.

Thanks Mark.
 
The code below has been modified from my Visual Basic Application and could be used for you. I was browsing folders and not files but I believe that there is a Files collection as well as a Folders collection. You will just have to make the appropriate substitutions below.

dim fso, fs, f, sPath

'initiate sPath
sPath = &quot;C:\rootdirectory&quot;

'create instance of fileSystemObject
Set fso = New FileSystemObject

'if sPath has no value the folders/files cannot be altered
If Len(sPath) = 0 Then Exit Sub

'get the root folder directory
Set f = fso.GetFolder(sPath)

'iterate through every folder within the root folder dir
For Each sf In f.SubFolders
'*** right here you will want to do something to view the
'files for each folder. I was working with folders and not
'files but this code (with some tweaking) should put
'you on the right track
'*****
Next sf
 
Exactly what I need. Thanks jkb17!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top