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下的纯pascal的十六进制转十进制

Delphi中查找指定文件的例程

Delphi 自定义产生随机字符串函数

Delphi 在ms access数据库中图像的存储和显示

Delphi 取当前目录下所有文件夹名和文件名

Delphi只获取文件名(不带扩展名)

Delphi中多线程下使用使用 unidac+mssql 需要注意的问题

Delphi spy++ 拖拽功能

Delphi android控制睡眠

Delphi stringgrid中回车换行

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



打赏

取消

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

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

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

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

评论

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