//******************************************************************************
//** 抓取指定路徑檔案名稱 _GetAllFiles--<自訂函數>
//**
//******************************************************************************
procedure _GetAllFiles(mask :String; isRecursiveSearch_ :Boolean; lst :TStrings);
var sr :TSearchRec;
tExt :String;
tDir :String;
begin
tExt := ExtractFileName(mask);
tDir := ExtractFilePath(mask);
if tDir[Length(tDir)] <> '\' then tDir := tDir+'\';
if FindFirst(mask, faAnyFile, sr) = 0 then
begin
repeat
lst.Add(Format('%s%s', [tDir, sr.Name]));
until FindNext(sr) <> 0;
SysUtils.FindClose(sr);
end;
if isRecursiveSearch_ then
begin
if FindFirst(tDir + '*.*', faDirectory, sr) = 0 then
repeat
if ((sr.Attr and faDirectory) = faDirectory) and (sr.name[1] <> '.') then
_GetAllFiles(Format('%s%s\%s', [tDir, sr.Name, tExt]), true, lst);
until FindNext(sr)<>0;
SysUtils.FindClose(sr);
end;
end;
2014-03-27
Delphi-抓取指定路徑檔案名稱
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言