Empty recycle bin

All tutorials created in C# to be posted in here.
1 post Page 1 of 1
Contributors
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Empty recycle bin
Shim
hey guys

with this snippet you can clear your recycle bin
Code: Select all
  enum RecycleFlags : uint
        {
            SHERB_NOCONFIRMATION = 0x00000001,
            SHERB_NOPROGRESSUI = 0x00000001,
            SHERB_NOSOUND = 0x00000004
        }
 
        [DllImport("Shell32.dll", CharSet = CharSet.Unicode)]
        static extern uint SHEmptyRecycleBin(IntPtr hwnd, string pszRootPath,
        RecycleFlags dwFlags);
               private void button1_Click(object sender, EventArgs e)
        {
            uint result = SHEmptyRecycleBin(IntPtr.Zero, null, 0);
        }
i am using button click event here by the way place the enum reclyflags lines after the
Code: Select all
  InitializeComponent();
        }
also you need the namespace
Code: Select all
using System.Runtime.InteropServices;
download sample
Recycle Bin.rar
enjoy

original source - http://ultimateprogrammingtutorials.blo ... ing-c.html
You do not have the required permissions to view the files attached to this post.
Find my programs on Softpedia
1 post Page 1 of 1
Return to “C-Sharp Tutorials”