这个要使用 System("xxxxx");delphi没有你要的这个函数,要么你调用deltree要么你自己写

解决方案 »

  1.   

    del 是内部命令…… 所以不性 用Delphi里的删除文件函数
      

  2.   

    删除目录及其下的所有文件?API最好:SHFileOperation
    unit DeleteFileToRecycleBin_Unit;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      Buttons, StdCtrls, ShellAPI;type
      TForm1 = class(TForm)
        OpenDialog1: TOpenDialog;
        Edit1: TEdit;
        DelToRecycleBin: TButton;
        SpeedButton1: TSpeedButton;
        procedure SpeedButton1Click(Sender: TObject);
        procedure DelToRecycleBinClick(Sender: TObject);
        function DelToRecycled(FileName:string):Boolean;
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.SpeedButton1Click(Sender: TObject);
    begin
      if opendialog1.Execute then edit1.Text:=opendialog1.FileName;
    end;procedure TForm1.DelToRecycleBinClick(Sender: TObject);
    begin
      if edit1.text='' then exit;
      if not FileExists(edit1.text) then Exit;
      if messagedlg('Delete file: '+edit1.text+' to recycle bin',mtconfirmation,[mbyes,mbno],0)=idyes
         then if deltorecycled(edit1.text) then  messagedlg('Delete file successfully!',mtinformation,[mbok],0);
    end;function TForm1.DelToRecycled(FileName: string): Boolean;
    var f:tshfileopstruct;
    begin
      fillchar(f,sizeof(f),#0);
      f.Wnd:=application.Handle;
      f.wFunc:=FO_DELETE;
      f.pFrom:=PChar(filename);
      f.pTo:=nil;
      f.fAnyOperationsAborted:= False;
      f.hNameMappings:= Nil;
      f.lpszProgressTitle:= Nil;
      f.fFlags:={FOF_SILENT or }FOF_ALLOWUNDO{ or FOF_NOCONFIRMATION};
    //不要FOF_ALLOWUNDO,就直接删除,要就到回收站
      result:=(shfileoperation(f)=0);
    end;end.
      

  3.   

    DEL命令运行的时候是要带参数的呀,你好像没有把它的参数给放进去
      

  4.   

    liu yang 你好!好象你的函数只能删除文件,不能删除目录啊?
    shfileoperation在NT下不能用。
      

  5.   

    删除文件函数 Erase
    删除目录函数 RmDir这是Delphi的内置函数。
      

  6.   

    你可以生成一个批处理,在最后加上DEL %0(好像是%0, 删除自已的意思)