Results 1 to 4 of 4

Thread: Searching Directories

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954

    Searching Directories

    I am searching a directory, my question is how do you search all of the subdirectories thereof?

    Here is my code..

    Private Sub cmdSearch_Click()
    Dim sFile As String
    Dim strClientID As String

    strClientID = txtClient.Text

    sFile = Dir$("C:\DigiSend\3-21\" & strClientID & "*.pdf") 'Get the first file

    Do While Len(sFile) > 0 'Loop until we run out of files
    lstQueryResults.AddItem sFile 'Add the file
    sFile = Dir$ 'Get the next file
    Loop

    End Sub


    Thanks!

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    you should use a recursive function call.

    use the vbDirectory attribute in the Dir function, then for each directory call the function. Recursion gets a bit confusing, but this is what its perfect for!
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3
    jim mcnamara
    Guest
    The best way is with the FileSystemObject

    Sample code here.

  4. #4
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    See second post here too, if you don't want FSO:

    http://161.58.186.97/showthread.php?...rchTreeForFile

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