How do you determine what folders are present inside the c: directory. Should i use the filesystemobject to do this or is there another way. For example, lets say i have tweo folders in my c: directory...how would i get the names of them. Thanks
Printable View
How do you determine what folders are present inside the c: directory. Should i use the filesystemobject to do this or is there another way. For example, lets say i have tweo folders in my c: directory...how would i get the names of them. Thanks
What is the filesystem object I've heard about?
To find all the folders in the C:\ drive (root)
You need to add a reference to the Microsoft Scripting Runtime for this to work. Enjoy!Code:Dim FSO As FileSystemObject
Dim fFolder As Folder
Dim fRoot As Folder
Private Sub Form_Load()
Set FSO = New FileSystemObject
Set fRoot = FSO.GetFolder("C:\")
For Each fFolder In fRoot.SubFolders
MsgBox fFolder.Name
Next
End Sub
Also, if you want to view *ALL* folders on C:
Code:Dim FSO As FileSystemObject
Dim fFolder As Folder
Dim fRoot As Folder
Private Sub Form_Load()
Set FSO = New FileSystemObject
ShowFolders ("C:\")
End Sub
Private Sub ShowFolders(Path As String)
Set fRoot = FSO.GetFolder(Path)
For Each fFolder In fRoot.SubFolders
MsgBox fFolder.Name
ShowFolders(fFolder.Path)
Next
End Sub