function GetDirFileName(Dir,ExtName: string): TStringList;
var
FSearchRec: TSearchRec;
FileList: TStringList;
FindResult: Integer;
begin
if Dir[length(Dir)] <> '\' then
Dir := Dir + '\';
FileList := TStringList.Create;
FindResult := FindFirst(Dir + '*.'+ExtName, faAnyFile, FSearchRec); //
try
while FindResult = 0 do
begin
if (FSearchRec.name <> '.') and (FSearchRec.name <> '..') then
FileList.Add(LowerCase(Dir + FSearchRec.Name));
FindResult := FindNext(FSearchRec);
end;
finally
SysUtils.FindClose(FSearchRec);
//FindClose(FSearchRec);
dir := '';
end;
Result := FileList;
end;
delphi 查找指定目录,指定扩展名的所有文件名
最新推荐文章于 2024-07-12 11:11:10 发布