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.
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;
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.
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.
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.