Page 1 of 1

Empty recycle bin

Posted: Mon Mar 25, 2013 2:59 am
by 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