刚做了一个,如下供参考:
procedure TthrFindFile.Find(Dir:String);
var
sch: TSearchRec;
stemp: String;
ADirectory:String;
begin
try
ADirectory:=Dir;
if ADirectory='' then
exit;
if FindFirst(ADirectory+'/'+ '*', faAnyfile, sch) = 0 then
begin
while FindNext(sch)=0 do
begin
if ((sch.Name = '.') or (sch.Name = '..')) then Continue;
if pos(UpperCase(sKeyWord),UpperCase(sch.Name))>0 then
begin
sName:=sch.Name;
spath:=ADirectory+'/'+sch.Name;
SynChronize(PutToGrid);
end;
if sch.Attr=faDirectory then //有子文件夹
begin
Find(ADirectory +'/'+sch.Name);
end
end;
end;
finally
Sysutils.FindClose(sch);
end;
end;