下面是一个进行目录搜索的例程,经过修改你可以搜索需要的文件类型
procedure Searchpath(path:string);
var
searchrec:TSearchRec;
ext:string;
begin
//在路径后面加上'/'
if path[length(path)]<>'/' then path := path + '/';
if FindFirst(path+'*.*', faAnyFile, SearchRec)<>0 then exit;
//判断是否为目录,是目录则循环
if(searchrec.Attr and faDirectory) <> 0 then
if(searchrec.name<>'.')and(searchrec.name<>'..')then searchpath(path+searchrec.name)
else begin
{此处加上你自已的判断文件后缀的代码
ext:=lowercase(extractfileext( searchrec.Name ));
if(ext='.bmp')or(ext='.jpg')then begin
...
end;
}
end;
while findnext(searchrec)=0 do begin
if(searchrec.Attr and faDirectory) <> 0 then
if(searchrec.name<>'.')and(searchrec.name<>'..')then searchpath(path+searchrec.name)
else begin
{此处加上你自已的判断文件后缀的代码
ext:=lowercase(extractfileext(searchrec.Name));
if(ext='.bmp')or(ext='.jpg')then begin
...
end;
}
end;
end;
findclose(searchrec);
end;