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

Finding folders within a directory.

Status
Not open for further replies.

KingofSnake

Programmer
Jul 25, 2000
73
US
Let's say I was currently in "C:\".

How could I get my program to find the names of all the folders contained in "C:\", like

"/program files", "/acessories", etc.
KingOfSnake - The only sports drink with ice crystals
(and marshmellos!)
 
FileSystemObject
Code:
Sub ShowFolderList(folderspec)
    Dim fs, f, f1, fc, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(folderspec)
    Set fc = f.SubFolders
    For Each f1 in fc
        s = s & f1.name 
        s = s &  vbCrLf
    Next
    MsgBox s
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top