Avatar of TomLenen
TomLenen
 asked on

[DELPHI] File Search

Hello all,

I'm trying to get my app to do a file search. It should search all drives and sub directories for a certain file(s). Some example source would be nice any help is highly appreciated. Thanx.

Sincerely, Tom Lenen
Delphi

Avatar of undefined
Last Comment
snehanshu

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ILE

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
swift99

Very elegant solution.

If your drive is very large and/or your directory structure very complex then you may wish to capture the sub-directories in a list and process them after closing the main routine's find.

Because of the nature of Windows I/O, this recursive function is also susceptible to speedup by multi-threading.  Off the top of my head, I estimate that you can get at least three times the overall performance and possibly better by careful use of multi-threading.  I suggest no more than three threads per CPU.
TAZI

Hi

Below is a procedure which will search through a directory looking for all file times with the extention .jpg

Hope this helps


procedure FindImages;
begin
var
  Search: TSearchRec;
  Path : String;
  Error: Integer;
  Bmp: TJPEGImage;        
  i : SmallInt;
 begin

  Error := FindFirst(Path + '*.jpg', faAnyFile - faDirectory, Search);
  if (Error = 0) then
     begin
       i := 0;
       SetLength(BmpArray,TotalImages);
       while (Error = 0) do
         begin
           Bmp := TJPEGImage.Create;
           Bmp.LoadFromFile(Path + Search.Name);
           BmpArray[i] := Bmp;
           Error := FindNext(Search);
           inc(i)
        end;
     FindClose(Search);
    end;
end;
end;

Regards
TAZI
SOLUTION
merry_prince

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CleanupPing

TomLenen:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
snehanshu

Hi!
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
https://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:

Split between ILE and merry_prince

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

...Snehanshu
EE Cleanup Volunteer