Recursion is the trick. Here is a partial function we use to loop through
all the files in our project hunting for DFM files to modify (source is old
from Delphi3 and there are cleaner ways to do some of it):

procedure TfrmMain.CheckFile(sValue: String);
var
  iTest: Integer;
  SearchRec: TSearchRec;
  sName: String;
begin
  iTest := FindFirst(sValue, faAnyFile, SearchRec);
  while iTest = 0 do
  begin
    try
      if (Trim(Searchrec.Name) = '.')
      or (Trim(Searchrec.Name) = '..') then
      begin
        Continue;
      end;
      sName := AddBackSlash(ExtractFilePath(sValue)) + Searchrec.Name;
      if DirectoryExists(sName) then
      begin
        CheckFile(AddBackSlash(sName) + '*.*');
        Continue;
      end;
      // your logic here
    finally
      iTest := FindNext(SearchRec);
    end;
  end;
end;

CheckFile('C:\*.*');

On Wed, Feb 23, 2011 at 4:34 PM, SoftTech <mi...@softtechks.com> wrote:

> Greetings All,
>
> Anyone have sample code on lopping thru all files in a folder and grabbing
> the name, type, size and date modified?
>
> Any pointers appreciated.
>
> Thanks,
> mike
> __________________________________________________
> Delphi-Talk mailing list -> Delphi-Talk@elists.org
> http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk
>
__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk

Reply via email to