Results 1 to 22 of 22

Thread: get every folder on the drive! recurse sub folders directories

Threaded View

  1. #1
    Frenzied Member dis1411's Avatar
    Join Date
    Mar 01
    Posts
    1,048

    Smile get every folder on the drive! recurse sub folders directories

    nice n easy..

    first click project -> references, and check Microsoft Scripting Runtime

    Win 98 SE and before will need a newer version of scrrun.dll

    VB Code:
    1. Public Function GetFolders(sStartFolder As String) As String
    2.     On Error Resume Next
    3.     Dim fso As New FileSystemObject
    4.     Dim f As Folder
    5.     Dim fldr As Folder
    6.     Set fldr = fso.GetFolder(sStartFolder)
    7.     GetFolders = fldr.Path & vbCrLf
    8.     If fldr.SubFolders.Count > 0 Then
    9.         For Each f In fldr.SubFolders
    10.             GetFolders = GetFolders & GetFolders(f.Path)
    11.         Next
    12.     End If
    13.     If Err.Number = 92 Then GetFolders = vbNullString
    14.     'windows did not allow the program to look inside this folder, so ignore it completely  (ie c:\system volume information in win2000)
    15. End Function

    note - the code got an edit recently... the following posts may or may not make sense
    Last edited by dis1411; Nov 5th, 2004 at 02:30 PM.

Posting Permissions

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