Ads by Lake Quincy Media
| Next Tip?
Home » CSharp

Empty Recycle Bin

28 June 2009 339 views One Comment
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
Loading ... Loading ...

Empty the Recycle Bin

Ths following code is used to empty the recycle bin using Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio

The namespace we have to use is:

using System.Runtime.InteropServices;

then create an enum for recylceflags like

enum RecycleFlgs : uint
{
   SHERB_NOCONFIRMATION = 0x00000001,
   SHERB_NOPROGRESSUI   = 0x00000002,
   SHERB_NOSOUND        = 0x00000004
}

creating an extern

[DllImport("Shell32.dll", CharSet = CharSet.Unicode)]
static extern uint EmptyRecycleBin
        (IntPtr hwnd,
        string pszRootPath,
        RecycleFlgs dwFlags);
               
Now the main function to call  the above defined code
 
public static void Main()
{
    uint result = EmptyRecycleBin (IntPtr.Zero, null, 0);
    Console.WriteLine ("Result: {0}", result);
}

Thanks and Regards
Meetu Choudhary
http://www.msdotnetmentor.com/

Popularity: 4%

Post to Twitter Tweet This Post

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Ads by Lake Quincy Media

One Comment »

  • Gaurav Arora said:

    Meetu great job
    keep it up!

Leave your response!

You must be logged in to post a comment.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes