请问delphi 如何删除外部文件?如 mytable.arj

解决方案 »

  1.   

    KAO,楼上的动作真快!UP!另外再加一个确认答案!
      

  2.   

    请问用winexec('erase mytable.arj',1);怎么不行。
      

  3.   

    //==============================================================================
    //删除目录(包括子目录一起删除)************************************************
    //==============================================================================
    procedure EraseDir(DirName:string);
    var DirInfo: TSearchRec;
        DosError: Integer;
    begin
      DosError := FindFirst(DirName+'\*.*', FaAnyfile, DirInfo);
      while DosError=0 do
      begin
        if ((DirInfo.Attr and FaDirectory)=faDirectory) and (DirInfo.Name<>'.') and (DirInfo.Name<>'..')
        then EraseDir(DirName + '\' + DirInfo.Name);
        {$IF DEFINED(WIN32) AND DECLARED(UsingVCL)}
        if ((DirInfo.Attr and FaDirectory)<>FaDirectory) and ((DirInfo.Attr and FaVolumeID)<>FaVolumeID)
        {$ELSE}
        if ((DirInfo.Attr and FaDirectory)<>FaDirectory)
        {$IFEND}
        then DeleteFile(pChar(DirName + '\' + DirInfo.Name));
        DosError := FindNext(DirInfo);
      end;
      SysUtils.FindClose(DirInfo);
      RemoveDirectory(PChar(DirName));
    end;
      

  4.   

    coolslob的东西是错的,不在回艘站中了
      

  5.   

    把一个文件删除放到回收站:
    uses
      ShellAPI;
    {$R *.dfm}procedure TForm1.FlatButton1Click(Sender: TObject);
    var
      SHFile:TSHFileOpStruct;
    begin
      SHFile.Wnd:=Handle;
      SHFile.pFrom:='D:\mp3.exe';
      SHFile.wFunc:=FO_DELETE;
      SHFileOperation(SHFile);
    end;