Re: FindFirstFile demo at MVPS
From: Stu (saet_at_steh.szerg)
Date: 09/23/04
- Next message: Jim Mack: "Re: IP range to CIDR list VB6 utility?"
- Previous message: Ian: "Re: VB6 Application Keeps Hanging????"
- In reply to: MikeD: "Re: FindFirstFile demo at MVPS"
- Next in thread: Stu: "Re: FindFirstFile demo at MVPS"
- Reply: Stu: "Re: FindFirstFile demo at MVPS"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 23 Sep 2004 14:09:23 +0100
> Depends what you mean by "the first x files". If you simply mean the
first
> x number of files found by FindFirst/FindNext, then just yes. Simply keep
a
> counter and quit searching when you've reached that count.
This is exactly what I mean! But I can not figure out where to count the
files. The obvious place is where the file is added to the list box but
because of the recursion I cant figure out how to stop the search once
lFoundFiles > x.
E.g. I have
GetFileInformation
...
...
If FP.Count >= lFileLimit Then
bStop = True 'Module level flag to stop searching
Else
sTmp = TrimNull(WFD.cFileName)
Debug.Print sRoot & sTmp
End If
...
...
Then I wrap the recursion in an if statement using the bStop flag:
SearchForFiles
...
...
...
'if valid ...
If hFile <> INVALID_HANDLE_VALUE Then
'This is where the method obtains the file
'list and data for the folder passed.
Call GetFileInformation(FP)
If Not bStop Then
Do
'if the returned item is a folder...
If (WFD.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) Then
...
...
Now if I search "r*" starting at "C:\" I get 11 files found when lFileLimit
= 2! What I want is a recursive findFirstFile to find the 1st occurrence of
a file. Once one file has been found I want to stop searching.
Also is this algorithm efficient for searching a limited no of files? I
think it is doing a depth first search (i.e. go down all folders first
before looking at the files).
Any ideas?
Cheers
Stu
- Next message: Jim Mack: "Re: IP range to CIDR list VB6 utility?"
- Previous message: Ian: "Re: VB6 Application Keeps Hanging????"
- In reply to: MikeD: "Re: FindFirstFile demo at MVPS"
- Next in thread: Stu: "Re: FindFirstFile demo at MVPS"
- Reply: Stu: "Re: FindFirstFile demo at MVPS"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|