Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I detect if a drive has a recycle bin in C#?

I have an application which uses the FOF_ALLOWUNDO with SHFileOperation in order to move files to the recycle bin.

Some removable drives do not have a recycle bin. In this case SHFileOperation deletes the files directly. I want to give a warning to the user that the files are going to be deleted directly.

In order to do this I need to know if the drive has a recycle bin.

like image 798
Norbert Willhelm Avatar asked Oct 10 '11 20:10

Norbert Willhelm


People also ask

Where is the Recycle Bin on my C drive?

To see the location of the Recycle Bin on your Windows computer, you will have to first show protected operating system files via the Control Panel, Folder Options applet. Once you have done that, open your C Drive. You will see the $Recycle. Bin folder.

Where is the Recycle Bin file location?

The Recycle Bin is a special set of folders that are located in a hidden folder or file (C:\$Recycle. Bin for modern versions of Windows, C:\recycler for Windows XP and older versions).

Does each drive have its own Recycle Bin?

Each user account on the PC will have their own separate Recycle Bin, and will be referenced by their Security Identifier (SID) in each drive's $Recycle. Bin. Items in the Recycle Bin still take up hard disk space and can be undeleted or restored back to their original location.


1 Answers

Use FOF_WANTNUKEWARNING.

Send a warning if a file is being permanently destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.

like image 136
Hans Passant Avatar answered Oct 14 '22 03:10

Hans Passant