 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Mon May 15, 2006 9:14 am Post subject: How does FindFirst/FindNext react, if the directory-contents |
|
|
How does FindFirst/FindNext react, if the directory-contents is
changed?
My guess is that it reads the complete directory (into an internal
structure like a list) when calling FindFirst() and FindNext() will
deliver the next contents, but I can't get any information about that
The problem which arises when using FindFirst/Next was that inside the
FindFirst/Next loop it might occur that the deletion of an already
delivered / the current / a not yet delivered file is necessary. So I
was quite irritated when having deleted a file some FindNext-s later
this filename was delivered. (So I had to insert a FileExists()-check
to make sure, that the delivered file really does exist).
If my guess is correct, I can handle these side-effects with
FileExists() (and this should be sufficent). If not, how is this done
and might there be other side-effects to keep an eye on.
Is FindFirst/FindNext just a wrapper around findrist/findnext (i.e. do
findrfirst/next behave the same way as FindFirst/Next)?
Thanks a lot,
Michael |
|
| Back to top |
|
 |
Pete Guest
|
Posted: Mon May 15, 2006 10:14 pm Post subject: Re: How does FindFirst/FindNext react, if the directory-cont |
|
|
MR wrote:
| Quote: | How does FindFirst/FindNext react, if the directory-contents is
changed?
|
Ummm, you can get most of the answers to your questions with a modest
amount of experimentation. Using FileExists() only covers half your
problem, does not help for newly created files.
You could use Windows API calls FindFirstChangeNotification() and
ReadDirectoryChangesW() to watch for changes as they happen.
If you'd rather stay within the VCL then you could use FindFirst() and
its pals to build a complete list of files to be processed, handle
those, then at the end of your processing build a new list and look for
added files. Repeat until no changes.
-- Pete |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|