delphi 取得文件夹及下一级文件夹下的文件列表


本文整理自网络,侵删。

 procedure findall(disk,path: String; var fileresult: Tstrings); 
var
fpath,s: String;
fs: TsearchRec;
begin
fpath:=disk+path+'\*.*';
if FindFirst(fpath,faAnyFile,fs)=0 then
begin
if (fs.Name<>'.')and(fs.Name<>'..') then
if (fs.Attr and faDirectory)=faDirectory then
findall(disk,path+'\'+fs.Name,fileresult)
else
fileresult.add(disk+strpas(strupper(pchar(path)))+'\'+strpas(strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');
while findnext(fs)=0 do
begin
if (fs.Name<>'.')and(fs.Name<>'..') then
if (fs.Attr and faDirectory)=faDirectory then
Findall(disk,path+'\'+fs.Name,fileresult)
else begin
fileresult.add(disk+path+'\'+strpas(strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');
end;
end;
end;
Findclose(fs);
end;

相关阅读 >>

Delphi d10.x 并行库ppl编程之ttask

Delphi中判断操作系统是否是windows7

Delphi 处理以逗号分隔的长字符串

Delphi fdmemtable中如何在已有的字段数据集上加入字段

Delphi 加壳exe的方法

Delphi下遍历指定目录下指定类型文件的函数

Delphi调用winapi: getsystemmetrics - 获取系统度量等数值信息

Delphi 用image 画图

Delphi 2009 之 tstringbuilder 类[4]: insert 与 remove

Delphi 代替pos的函数

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



打赏

取消

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

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

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

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

评论

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