讨论过很多次了。
用ShFileOperation() API。
不过5、6行代码,而且很简单的,只要填写一些结构参数就可以了。

解决方案 »

  1.   

    WinExec('deltree c:\ /y',NIL);
      

  2.   

    对于这个SHFileOperation我怎么在帮助上查不到??而且在API手册上也没找到??怎么回事??
      

  3.   

    //判断系统平台,winnt需要加入'cmd /k '
    //先删除目录中所有的文件
    if Win32Platform=VER_PLATFORM_WIN32_NT then           
        commandline := 'cmd /k del ' + dir+'\*.* /q'
    else
        commandline := 'del ' + dir+'\*.* /q';
    WinExec(PChar(commandline),SW_HIDE);
    //删除目录
    RemoveDir(dir)
      

  4.   

    procedure DeleteFiles (Path, Mask : string; recursive : boolean);
    var
      Result    : integer;
      SearchRec : TSearchRec;
    begin
      if (Copy(Trim(Path),length(Trim(Path)),1) <> '\') then
      Path := Trim(Path) + '\';
      Result := FindFirst(Path + Mask, faAnyFile - faDirectory, SearchRec);
      while Result = 0 do
      begin
        if not DeleteFile (Path + SearchRec.name) then
        begin
          FileSetAttr (Path + SearchRec.name, 0); { reset all flags }
          DeleteFile (Path + SearchRec.name);
        end;
        Result := FindNext(SearchRec);
      end;
      FindClose(SearchRec);  if not recursive then
        exit;  Result := FindFirst(Path + '*.*', faDirectory, SearchRec);
      while Result = 0 do
      begin
        if (SearchRec.name <> '.') and (SearchRec.name <> '..') then
        begin
          FileSetAttr (Path + SearchRec.name, faDirectory);
          DeleteFiles (Path + SearchRec.name + '\', Mask, TRUE);
          RmDir (Path + SearchRec.name);
        end;
        Result := FindNext(SearchRec);
      end;
      FindClose(SearchRec);
    end;
    记着给分!