Search This Blog

Tuesday, January 27, 2009

How to empty recycle bin programmatically?

While processing or writing huge files to disk, its quite possible that disk will go out of space. To Squeeze and to get more disk space, its a good idea to clean the recycle bin. But how to do it programmatically?


You can use the api - SHEmptyRecycleBin(). See the code snippet below.

SHEmptyRecycleBin( NULL, NULL, SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND );

Note:
By modifying the options, you can show progress UI, Show confirmation dialog and play sound on finishing task. Just remove the unwanted flags.

No comments: