就是说如果参数是文件名,就删除这个文件。如果是文件夹名,就删除这个文件夹和里面所有的文件~

解决方案 »

  1.   

    uses shellapi;function CleanDir(const Source:string): boolean;
    var
     fo: TSHFILEOPSTRUCT;
    begin
     FillChar(fo, SizeOf(fo), 0);
     with fo do
     begin
       Wnd := 0;
       wFunc := FO_DELETE;
       pFrom := PChar(source+#0);
       pTo := #0#0;
       fFlags := FOF_NOCONFIRMATION+FOF_SILENT;
     end;
     Result := (SHFileOperation(fo) = 0);
    end;
      

  2.   

    uses ShellAPI; //use SHFileOperation()、TSHFileOpStruct function DeleteDirectory(mSource: string): Boolean; 
    var 
    vSHFileOpStruct: TSHFileOpStruct; 
    begin 
    FillChar(vSHFileOpStruct, SizeOf(vSHFileOpStruct), 0); 
    with vSHFileOpStruct do 
    begin 
    Wnd := Application.Handle; 
    wFunc := FO_DELETE; 
    pFrom := PChar(mSource + #0); 
    pTo := #0#0; 
    fFlags := FOF_NOCONFIRMATION+FOF_SILENT; 
    end; 
    Result := SHFileOperation(vSHFileOpStruct) = 0; 
    end; { DeleteDirectory }