Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send a File to the Recycle Bin

Tags:

c#

recycle-bin

Currently I'm using the following function

file.Delete(); 

But how can I use this function to send a file to the recycle bin instead of just deleting it outright?

like image 695
muttley91 Avatar asked Jul 19 '10 15:07

muttley91


People also ask

What key sends files to the Recycle Bin?

To access the Recycle Bin: Press Windows + D for the desktop. Press R until you get to the Recycle Bin and press Enter.

Can't send files Recycle Bin?

When your deleted files don't go directly to the Recycle Bin, you must first ensure that your Recycle Bin settings are configured correctly. You must check that the “Don't move files to the Recycle Bin” option is not selected. On your desktop, right-click the Recycle Bin icon and then click Properties.

What does putting a file in the Recycle Bin mean?

When you delete items, however, they are not deleted permanently, but placed into the Recycle Bin. The Recycle Bin acts as a 'holding bay' for deleted items until you are ready to delete them permanently. Deleted items can be recovered from the Recycle Bin if required, but there are exceptions.

What happens when you move a file to the Recycle Bin?

The Answer Moving a file to the Recycle Bin does just that, moves the file. Its contents are left completely intact. Deleting a file from the Recycle Bin (or deleting it directly using Shift+Delete) removes the file name entry from the folder.


1 Answers

Use FileSystem.DeleteFile and specify the right RecycleOption.

While this will work with UI Interactive Apps, it will not work with non UI interactive apps like a Windows Service app.

like image 149
NG. Avatar answered Sep 29 '22 09:09

NG.