1. 程式人生 > >Delphi 支援萬用字元刪除檔案!

Delphi 支援萬用字元刪除檔案!

procedure DeleteFileEx(FileName:string);
var
    FileDir:string;
    FileStruct:TSHFileOpStruct;
begin
    FileDir   :=  FileName;// 'C:\temp\abc*.txt';
    FileStruct.Wnd   :=0;
    FileStruct.wFunc   :=FO_delete;
    FileStruct.pFrom:=Pchar(FileDir+#0);
    FileStruct.fFlags:=FOF_NOCONFIRMATION;
    FileStruct.pTo   := ' ';
   // if   SHFileOperation(FileStruct)=0   then
   //       showmessage( 'The   Files   Has   Been   Deleted! ');
end;