"Bruce Roberts" <b...@bounceitattcanada.xnet> wrote in message <news:J_hW8.5424$H67.28404@tor-nn1.netcom.ca>...
> Rather than using text file i/o you could collect the results in a string
> list and then write them in one operation.
> procedure GetAllFiles (const directory, mask : string; results : tStrings);
> > var
> > search: TSearchRec;
> > begin
> > if FindFirst(directory + mask, $23, search) = 0 then
> > begin
> > repeat
> results.Add (directory + search.Name);
> > until FindNext(search) <> 0;
> > end;
> > if FindFirst(directory + '*.*', faDirectory, search) = 0 then
> > begin
> > repeat
> > if ((search.Attr and faDirectory) = faDirectory) and
> > (search.Name[1] <> '.') then
> GetAllFiles (directory + search.Name + '\', mask, results);
> > until FindNext(search) <> 0;
> > FindClose(search);
> > end;
> > end;
> > procedure TForm1.Button1Click(Sender: TObject);
> var rslt : tStringList;
> > begin
> rslt := tStringList.Create;
> try
> GetAllFiles ('C:\', '*.com', rslt);
> finally
> rslt.SaveToFile ('c:\temp\filelist.txt');
> rslt.Free;
> end;
> > end;
> This has the advantage of making GetAllFiles more flexible and hence
> reuseable. In testing, for example, one could simply use
> memo1.Clear;
> GetAllFiles ('c:\', '*.com', memo1.Lines);