文件夾查找文件(一個文件夾文件查找函數 Delphi),
procedure TfrmMain.SearchPath(path, filename: string; recurse: Boolean;
List: TStringList); //recurse 是否包遞歸查找目錄
procedure Traverse(APath: string);
var
f: TSearchRec;
I: Integer;
begin
if recurse then
begin
if FindFirst(APath + filename,faDirectory,f) = 0 then
repeat
if (f.Name[1] <> '.') then
Traverse(IncludeTrailingPathDelimiter(APath + f.Name));
until FindNext(f) <> 0;
FindClose(f);
end;
if FindFirst(APath + filename,faReadOnly or faHidden or faSysFile or faArchive, f) = 0 then
repeat
List.Add(APath + f.Name);
until FindNext(f) <> 0;
FindClose(f);
end;
begin
Traverse(IncludeTrailingPathDelimiter(path));
end;