How to sent file to recycle bin in delphi
30th June 2008
hi all delphi reader, today i want to share how to delete or sent files to recycle bin so after deletetion we can retrieve again the file.
Here’s a Delphi procedure that can delete a file with the ability to undo by sending the file to the “Recycle Bin. “Function bFileDelete” will return True if the operation was successful.
uses ShellAPI;
function bFileDelete(AFileName:string): boolean;
var Struct: TSHFileOpStruct;
pFromc: array[0..255] of char;
Resultval: integer;
begin
if not FileExists(AFileName) then begin
Result := False;
exit;
end else begin
fillchar(pfromc,sizeof(pfromc),0) ;
StrPcopy(pfromc,expandfilename(AFileName)+#0#0) ;
Struct.wnd := 0;
Struct.wFunc := FO_DELETE;
Struct.pFrom := pFromC;
Struct.pTo := nil;
Struct.fFlags:= FOF_ALLOWUNDO or FOF_NOCONFIRMATION or FOF_SILENT;
Struct.fAnyOperationsAborted := false;
Struct.hNameMappings := nil;
Resultval := ShFileOperation(Struct) ;
Result := (Resultval = 0) ;
end;
end;
well hope that usefull for you all delphi readers.
| 2.7 |



