procedure TForm1.FindFile(strDir,strName:string);
var
sr: TSearchRec;
FileAttrs: Integer;
begin
StringGrid1.RowCount := 1;
if CheckBox1.Checked then
FileAttrs := faReadOnly
else
FileAttrs := 0;
if CheckBox2.Checked then
FileAttrs := FileAttrs + faHidden;
if CheckBox3.Checked then
FileAttrs := FileAttrs + faSysFile;
if CheckBox4.Checked then
FileAttrs := FileAttrs + faVolumeID;
if CheckBox5.Checked then
FileAttrs := FileAttrs + faDirectory;
if CheckBox6.Checked then
FileAttrs := FileAttrs + faArchive;
if CheckBox7.Checked then
FileAttrs := FileAttrs + faAnyFile;
if FindFirst(strDir+strName, FileAttrs, sr) = 0 then
begin
repeat//find the file
if (sr.Attr and FileAttrs) = sr.Attr then
begin
CopyFile(pchar(sr.Name),pchar('D:\shiyan\'+sr.Name),true);//Copy the file do the dest dir
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FindFile('D:\Program Files\Borland\Delphi7\Projects\','*.Txt');
end;