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 如何删除动态数组的指定元素

Delphi将图片转换成文本支持转换回去

Delphi 窗体内控件实现滚动字母

Delphi xe 使用savestate保存firemonkey状态的示例

Delphi 设置系统默认打印机

Delphi 中让嵌入窗体的 webbrowser 控件无边框

Delphi 设置文本框中光标的位置在最后

Delphi 用dbexpress处理jpg图片

Delphi 记录鼠标点击坐标

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



打赏

取消

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

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

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

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

评论

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