Delphi 删除目录下指定类型文件


本文整理自网络,侵删。

 
procedure Deletefiles(APath, AFileSpec: string); //*.txt   *.*
var
  lSearchRec:TSearchRec;
  lFind:integer;
  lPath:string;
  dirname: string;
begin
  lPath := IncludeTrailingPathDelimiter(APath);
  if DirectoryExists(lPath) then
  begin
    lFind := FindFirst(lPath+AFileSpec,faAnyFile,lSearchRec);
    while lFind = 0 do
    begin
      dirname := lSearchRec.Name;
      if (dirName <> '.')
      and (dirName <> '..')
      and (FileExists(lPath+dirName)) then
      begin

        DeleteFile(lPath+dirname);

      end;

      lFind := FindNext(lSearchRec);
    end;
    FindClose(lSearchRec);
  end;
end;

相关阅读 >>

Delphi调用程序版本信息的方法

Delphi取得cxgrid 合计数

Delphi screencap 截图

Delphi生成guid

Delphi adoconnection1 事务

Delphi 与 graphics gdi+ 基础学习

Delphi文件无法拖拽功能失效

如何在Delphi xe中通过ftp下载文件

Delphi10.x dpr文件

Delphi 2009 中 tstrings 与 tstream 的增强

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



打赏

取消

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

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

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

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

评论

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