Board index » delphi » Deleting file to Recycled Bin

Deleting file to Recycled Bin

Hello!
Does anyone know how I can delete file to Recycled Bin?

I try
  DeleteFile (AFileName)
but it remove file from disk.

Thanks.

 

Re:Deleting file to Recycled Bin


Quote
> I try
>   DeleteFile (AFileName)
> but it remove file from disk.

try this:
function DeleteFileWithUndo(sFileName: string): boolean;
var
  fos: TSHFileOpStruct;
begin
  FillChar(fos, SizeOf(fos), 0);
  with fos do
    begin
      wFunc := FO_DELETE;
      pFrom := PChar(sFileName);
      fFlags := FOF_ALLOWUNDO or FOF_NOCONFIRMATION or FOF_SILENT;
    end;
  Result := (0 = ShFileOperation(fos));
end;

--
Met vriendelijke groeten / With kind regards,
Sam Francke.

Other Threads