delphi 遍历目录


本文整理自网络,侵删。

 function MakeFileList(Path,FileExt:string):TStringList ;
var
sch:TSearchrec;
begin
Result:=TStringlist.Create;

if rightStr(trim(Path), 1) <> '\' then
Path := trim(Path) + '\'
else
Path := trim(Path);

if not DirectoryExists(Path) then
begin
Result.Clear;
exit;
end;

if FindFirst(Path + '*', faAnyfile, sch) = 0 then
begin
repeat
Application.ProcessMessages;
if ((sch.Name = '.') or (sch.Name = '..')) then Continue;
if DirectoryExists(Path+sch.Name) then
begin
Result.AddStrings(MakeFileList(Path+sch.Name,FileExt));
end
else
begin
if (UpperCase(extractfileext(Path+sch.Name)) = UpperCase(FileExt)) or (FileExt='.*') then
Result.Add(Path+sch.Name);
end;
until FindNext(sch) <> 0;
SysUtils.FindClose(sch);
end;
end;

相关阅读 >>

Delphi中限制鼠标的移动区域

Delphi 调用clipboard 收集剪切板信息

Delphi xe 制作的萤光时钟,可改作屏保

Delphi 如何在twebbrowsers之间传递数据

d10环境下调用hidcontroller1.0.35获取数据乱码问题

Delphi windows 编程[2] - 学习窗体生成的过程二

Delphi 实现简易语音发音(基于tts方式)

Delphi idhttp 实战用法(tidhttpex)

Delphi 时间转换为gmt格式

Delphi中指针和地址切换的方法

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



打赏

取消

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

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

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

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

评论

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