修改星号那一段
调用方式:
第二原来是文件名 直接用文件夹名就行了
function TForm1.SearchFile(mainpath, filename: string;
var foundresult: TStrings): Boolean;
var
i:Integer;
Found:Boolean;
subdir1:TStrings;
searchRec:TSearchRec;
s:string;
begin
Found:=false;
if trim(filename)<>'' then
begin
subdir1:=TStringList.Create;
if (FindFirst(mainpath+'*.*',faDirectory,searchRec)=0) then
begin
if IsValidDir(SearchRec) then
subdir1.Add(SearchRec.Name);
while (FindNext(SearchRec)=0 ) do
begin
if IsValidDir(SearchRec) then
subdir1.Add(SearchRec.Name);
end;
end;
FindClose(SearchRec);
***********************************************************************
if (copy(mainpath,length(mainpath)-length(filename),length(filename)=filename) then
begin
Found:=true;
foundresult.Add(mainpath);
end;
************************************************************************
for i:=0 to subdir1.Count-1 do
found:=SearchFile(mainpath+subdir1.Strings+'/',FileName,foundresult);
subdir1.Free;
end;
result:=found;
end;