C # implements cleanup Recycle Bin Garbage

Source: Internet
Author: User

<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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.