|
-
Jul 24th, 2001, 12:13 PM
#1
getting folder name
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
-
Jul 24th, 2001, 12:38 PM
#2
Addicted Member
What is the filesystem object I've heard about?
-
Jul 24th, 2001, 12:47 PM
#3
Fanatic Member
To find all the folders in the C:\ drive (root)
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
You need to add a reference to the Microsoft Scripting Runtime for this to work. Enjoy!
-
Jul 24th, 2001, 12:57 PM
#4
Fanatic Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|