Results 1 to 4 of 4

Thread: getting folder name

  1. #1
    Dimension
    Guest

    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

  2. #2
    Addicted Member
    Join Date
    Feb 2001
    Posts
    140
    What is the filesystem object I've heard about?
    -Nean

  3. #3
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    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!
    -Excalibur

  4. #4
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    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
    -Excalibur

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width