CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: FindFirstFile

  1. #1
    Join Date
    Apr 2001
    Posts
    7

    FindFirstFile

    Hi, I can use the win32APi FindFirstFile ok, but want to be able to get it to look for files recursively, ie include all subdirectries within current path. ie c:\te*.txt ie find the first file that meets this criteria wherever it is on c: drive. It seems to only search in the root directory in the example above. Is there any way to make it search all subdirectories, or is there another API that will do this? thanks very much! ps I can do it with the DIR$ and an array, but I want to use an API.
    private Sub Command1_Click()
    Dim sFileName as string
    Dim FindFileData as WIN32_FIND_DATA
    Dim FindFileDataReturn as Long
    FindFileDataReturn = FindFirstFile("c:\te*.txt", FindFileData)
    Text1.Text = FindFileDataReturn
    Text2.Text = FindFileData.cFileName
    End Sub


    I have declared the api etc in a module.


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: FindFirstFile

    there is no easy way. What u need to do is use FindFirstFile & FindNextFile in the root directory. and recursively calling the function on the subsequent directory.

    But, the catch is, you need to do it twice, first for directory first, then only for files.

    HTH

    cksiow
    http://vblib.virtualave.net - share our codes



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

Featured