Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

List files and folders - FSO


Option Explicit
Dim X As New FileSystemObject

Dim F As Folder
Set F = X.GetFolder( "d:\data" )
GetFolderList F


Sub GetFolderList(aFolder As Folder)
'Put code here if you want to stop the search    If SearchStop = False Then Exit Sub
For Each tempFile In aFolder.Files
    Print tempFile.Name
Next

Dim tempFolder As Folder
For Each tempFolder In aFolder.SubFolders
    Print tempF.ParentFolder & "\"; tempF.Name
   GetFolderList tempFolder
Next
End Sub