Link to home
Start Free TrialLog in
Avatar of eNarc
eNarcFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Pause a File Search

Hi, how do I search a folder and sub folders saving the path to a Stringlist.

when the file count reaches 1000 it will save the SL to a file and clears the SL back to 0 and carries on searching through the files.

the only problem that I'm having is that when its saving the sub directrices are still active and still searching, and it doesn't collect all the files.

as the file count in the files is not the file count that was counted so when its saving its missing files.

this is what I'm using to search, though how do I add the pause all the searches and when the save is complete it resumes all the searches

function BeginSearch(Path:string):string;
var
  sr: TSearchRec;
begin
  Path:=IncludeTrailingBackSlash(Path);
  if FindFirst(Path + '*.*', faAnyFile, sr) = 0 then begin
    repeat
      Application.ProcessMessages;
      if (sr.Name <> '.') and (sr.Name <> '..') then begin
        if (sr.Attr and faDirectory)>0 then begin
          BeginSearch(Path+sr.Name);
        end else begin
          FileSL.add(Path+sr.Name);            
      end;
      end;       
    until FindNext(sr) <> 0;
    FindClose(sr);
  end;
end;
ASKER CERTIFIED SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eNarc

ASKER

though it doesn't collect all the files as while its saving the other subfiles are being searched at the same time I need to be able to pause all searches while it saves and then once its done continues as if it wasn't paused.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eNarc

ASKER

good