本文整理自网络,侵删。
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源码webbrowser多次执行documentcomplete
Delphi 10.4.1 edgebrowser 模拟操作网页方法
Delphi 程序运行提示 “database login”对话框,让输入adoconnection1 的username和password
更多相关阅读请进入《Delphi》频道 >>