Results 1 to 8 of 8

Thread: Searching File in Folders - Dir()

Threaded View

  1. #5
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: Searching File in Folders - Dir()

    Here is the code to do what you need using filesystemobject and recursion

    VB Code:
    1. Private Sub Form_Activate()
    2.     PrintMyJunk 1, "c:\Program Files"
    3. End Sub
    4.  
    5. Public Sub PrintMyJunk(Level As Integer, MyDir As String)
    6.     Dim fsObj As New FileSystemObject
    7.     Dim myFolder As Folder
    8.  
    9.     For Each myFolder In fsObj.GetFolder(MyDir).SubFolders
    10.         Select Case Level
    11.             Case Is = 1
    12.                 Debug.Print "Client = " & myFolder.Name
    13.             Case Is = 2
    14.                 Debug.Print "Category = " & myFolder.Name
    15.             Case Is = 3
    16.                 Debug.Print "Source = " & myFolder.Name
    17.             Case Is = 4
    18.                 Debug.Print "GUID = " & myFolder.Name
    19.         End Select
    20.                
    21.         If Level < 4 Then
    22.             PrintMyJunk Level + 1, myFolder.Path
    23.         End If
    24.     Next
    25. End Sub
    Last edited by umilmi81; Oct 13th, 2005 at 05:57 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
  •  



Click Here to Expand Forum to Full Width