Go Back   Wiki NewForum | Latest Entertainment News > Career Forum & Tips > Tech Forum & Tutorial > Oracle Database, SQL, Application, Programming


Delete files with the ability to undo or recycle


Reply
Views: 1914  
Thread Tools Rate Thread
  #1  
Old 08-20-2010, 10:58 AM
bholas bholas is offline
Award Winner
 
Join Date: Apr 2010
Posts: 4,977
Default Delete files with the ability to undo or recycle

Windows will not let the user or your program undo file delete operations that your perform using low-level functions such as DeleteFile() from your program. Following function, however, will delete a file with the ability to undo (recycle) by sending the file to the "Recycle Bin."

uses ShellAPI;

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;
To delete a file, simply pass the file name to DeleteFileWithUndo() and it will return True if the operation was successful.

Reply With Quote
Reply

Tags
programming tips

New topics in Oracle Database, SQL, Application, Programming





Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
WikiNewForum)