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 firedac sqlite不能插入"&"符号

Delphi执行sql提示“不正常地定义参数对象”,“提供了不一致或不完整的信息”错误

Delphi 调用exitwindows 关闭系统

Delphi 实现窗体随着鼠标移动

Delphi mscomm控件串口收发程序

Delphi线程中动态创建ado控件

Delphi 将image组件的图片保存为jpg格式图片方法

Delphi txt日志log

Delphi 类的声明

winapi 字符及字符串函数(1): charlower - 字符或字符串转小写

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



打赏

取消

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

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

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

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

评论

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