<summary>
Cleaning up trash at the Recycle Bin
</summary>
<param name= "Sender" ></param>
<param name= "E" ></param>
private void Button1_Click (object sender, EventArgs e)//button Event
{
Clear (True,this);
}
[DllImportAttribute ("Shell32.dll")]
private static extern int Shemptyrecyclebin (IntPtr handle, string root, int falgs);
const int sherb_noconfirmation = 0x000001;
const int Sherb_noprogressui = 0x000002;
const int sherb_nosound = 0x000004;
<summary>
Emptying the Recycle Bin
</summary>
<param name= "Tip" > whether to prompt </param>
<param name= "form" > Current form, General incoming this</param>
public static void Clear (bool tip, System.Windows.Forms.Form Form)
{
System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.No;
if (TIP)
result = System.Windows.Forms.MessageBox.Show ("OK to empty the Recycle Bin?", "Friendly Tips", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information);
Else
result = System.Windows.Forms.DialogResult.Yes;
if (result = = System.Windows.Forms.DialogResult.Yes)
{
Shemptyrecyclebin (form. Handle, "", Sherb_noconfirmation + Sherb_noprogressui + sherb_nosound);
}
}
C # implements cleanup Recycle Bin Garbage