procedure TForm1.FindAll(Path,sfile: String);
var
sr:TSearchRec;
fr:Integer;
begin
if length(path)<>3 then
Path:=path+'/*.*'
else
Path:= path+'*.*';
fr:=FindFirst(Path,faAnyFile,sr);
while fr=0 do
begin
if (sr.Attr=faDirectory)and(sr.Name<>'.')and(sr.Name<>'..') then
FindAll(sr.name+'/*.*',sfile) //递归查找下一个目录
else
if pos(sfile,sr.name)>0 then
begin
//处理文件
showmessage(sr.name);
end;
fr:=FindNext(sr);
end;
FindClose(sr);
end;
//调用时
FindAll('c:/abc','cd')