delphi 查找某目录下的特定文件


本文整理自网络,侵删。

 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整理六(数据与记录)

Delphi 构建时间 -encodedatetime … tryencodedatetime

Delphi 2009 泛型容器单元(generics.collections)[3]: tstack<t>

Delphi idhttpserver使用注意问题

Delphi d10.x 安卓app开发中按返回键后程序不退出程序的方法

Delphi中使用isuperobject解析json数据

Delphi unigui中cookies使用中文汉字的方法

Delphi pagecontrol.ttabsheet与drivecombobox.items同步

Delphi 检测网络是否连通

Delphi edit 让密码变成点

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...