Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Feb : How do FindFirst and FindNext work?

www.cryer.info
Managed Newsgroup Archive

How do FindFirst and FindNext work?

Subject:How do FindFirst and FindNext work?
Posted by:"Anatoly" (anatoly..@gmail.com)
Date:Mon, 13 Feb 2006 11:30:53 +0100

Hi!

Here is a code sample that does not work:
var
   sr:           TSearchRec;
   sSomePath : String;

if FindFirst(sSomePath + '*.xml', 0, sr) then begin
   blablabla;
   blablabla;
   repeat
     blabla; // I process the xml file found in "sSomePath"
     blblbl; // Here I add a new xml file to the directory "sSomePath"
     blabla;
   // I expect FindNext(sr) to find the new file but it doesn't and
   // the loop is finished.
   until FindNext(sr) <> 0;
end;

So it seems that FindFirst discoveres all the files in directory, puts
aside a list of them and it is this list that FindNext works with. The
problem is I do not see how it happens and how I could affect this
behavoir. I need to be able to add files the directory "sSomePath" after
a call to FindFirst and I need FindNext to be able to find these files
afterwords.

All I see is that if I add a file before the call FindFirst then it is
found by FindNext. But if  I add a new file after a call to FindFirst
then the new file is not found by FindNext.

Best regards,
Anatoly

Glossary

File Types

Replies:

www.cryer.info
Managed Newsgroup Archive