delphi搜索文件夹和文件


本文整理自网络,侵删。

 function FindFile(Path: string): string; {搜索文件夹和文件}
var
Sr: TSearchRec;
CommaList: TStringList;
s: string;
dt: TDateTime;
begin
commalist := Tstringlist.Create;
try
Findfirst(path + '*.*', faAnyFile, sr);
if ((Sr.Attr and faDirectory) > 0) and (Sr.Name <> '.') then
begin
dt := FileDateToDateTime(sr.Time);
s := FormatDateTime('yyyy-mm-dd hh:nn', dt);
commalist.add('*' + s + sr.name);
end;
while findnext(sr) = 0 do
begin
if ((Sr.Attr and faDirectory) > 0) and (Sr.Name <> '..') then
begin
dt := FileDateToDateTime(sr.Time);
s := FormatDateTime('yyyy-mm-dd hh:nn', dt);
commalist.add('*' + s + sr.name);
end;
end;
FindClose(sr);
FindFirst(path + '*.*', faArchive + faReadOnly + faHidden + faSysFile, Sr);
if Sr.Attr <> faDirectory then
begin
dt := FileDateToDateTime(sr.Time);
s := FormatDateTime('yyyy-mm-dd hh:nn', dt);
commalist.add('\' + s+ Format('%.0n', [sr.Size / 1]) + '|' + sr.name);
end; //Inttostr(
while findnext(sr) = 0 do
begin
if (sr.Attr <> faDirectory) then
begin
dt := FileDateToDateTime(sr.Time);
s := FormatDateTime('yyyy-mm-dd hh:nn', dt);
commalist.add('\' + s +Format('%.0n', [sr.Size / 1]) + '|' + sr.name);
end;
end;
FindClose(Sr);
except
end;
Result := commalist.Text;
commalist.Free;
end;

相关阅读 >>

Delphi 文件查找findfirst,findnext,findclose

Delphi tfilestream 的读写 合并文件

Delphi xe system.netencoding 字符串base64编码解码

Delphi直接实现分享图片功能

Delphi copyrect实现的几个图片的转换效果

Delphi中tlistview控件使用

Delphi 缓冲文件流-tbufferedfilestream tfilestream 性能测试

Delphi获取星期几

Delphi 10.3 中安装程序自动升级插件autoupgrader_pro_v5.2

Delphi删除文件和文件夹

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



打赏

取消

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

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

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

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

评论

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