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 applicationevents1 webbrowser1屏蔽右键菜单

Delphi 数据库处理密码防止sql注入

Delphi app如何禁掉安卓锁屏

Delphi判断系统是否64位

Delphi twebbrowser 屏蔽右键菜单

Delphi dll初始化和退出处理

Delphi中strtodatetime函数tformatsettings参数的使用

Delphi 图像自动调整显示

Delphi线程简单创建、挂起、激活与终止

Delphi xe5发送短信以及读取短信代码

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



打赏

取消

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

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

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

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

评论

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