Results 1 to 2 of 2

Thread: Searching for File

  1. #1

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Searching for File

    Hi all,

    I need to search for a file in a folder. I found a ton of code for this doing a quick search but I must be tired or something because I can't put two and two together. I need to search about 50 folders which the paths are located in a list box (app.path & list1.list(0, 1, 2... 50).

    Can someone help me out with this one?

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Searching for File

    I haven't tested this 100% but it should work (i think)

    VB Code:
    1. Private Declare Function SearchTreeForFile Lib "imagehlp" (ByVal RootPath As String, ByVal InputPathName As String, ByVal OutputPathBuffer As String) As Long
    2. Private Const MAX_PATH = 260
    3. Private Sub Command1_Click()
    4.     Dim tempStr As String, Ret As Long
    5.     'create a buffer string
    6.     tempStr = String(MAX_PATH, 0)
    7.     'returns 1 when successfull, 0 when failed
    8.     For x = 0 To List1.ListCount - 1
    9.         Ret = SearchTreeForFile(List1.List(x), "myfile.ext", tempStr)
    10.         If Ret <> 0 Then
    11.             Debug.Print "Located file at " + Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1)
    12.         Else
    13.             Debug.Print "File not found in " & List1.List(x)
    14.         End If
    15.     Next
    16.  
    17. 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
  •  



Click Here to Expand Forum to Full Width