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?
To access the Recycle Bin: Press Windows + D for the desktop. Press R until you get to the Recycle Bin and press Enter.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With