本文整理自网络,侵删。
procedure ChangeDir(dir: string; SL: TStringList);
var
SearchRec : TSearchRec;
Attr : integer;
Found : integer;
ExtFileName:string;
temstr:string;
begin
SL.Clear;
//查找该目录下所有*.jpg的文件,并将文件路径及文件名添加到SL
temstr:=dir+'\*.jpg';
Attr := faAnyFile;
Found := FindFirst(temstr, Attr, SearchRec);
while Found = 0 do
begin
//获取扩展名
//ExtFileName:=LowerCase(ExtractFileExt(SearchRec.Name));
try
SL.Add(dir+'\'+SearchRec.Name);
except
end;
Found := FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
相关阅读 >>
Delphi 的tstringbuilder防止服务器内存碎片化
更多相关阅读请进入《Delphi》频道 >>