Click to See Complete Forum and Search --> : FindFirstFile


nickwa
April 29th, 2001, 09:43 PM
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.

cksiow
April 30th, 2001, 01:36 AM
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