批量删除同类文件的函数


procedure DelFiles(f: string);

var

  SearchRec: TSearchRec;

begin

  ChDir(ExtractFilePath(f));  //进入文件路径

  FindFirst(f, faAnyFile, SearchRec);

  repeat

    if FileExists(SearchRec.Name) then

    begin

      //FileSetAttr(SearchRec.Name,0); //修改文件属性为普通属性值

      DeleteFile(SearchRec.Name); //删除文件

    end;

  until(FindNext(SearchRec)<>0);

  FindClose(SearchRec);

end;


 
   

你可能感兴趣的:(文件)