記得先using Sytem Runtime.InteropServices;
using System.Runtime.InteropServices;
const int SHERB_NOCONFIRMATION = 0X000001; //無確認視窗
const int SHERB_NOPROGRESSUI = 0X000002; //不顯示進度列
const int SHERB_NOSOUND = 0X000004; //不播放聲音
[DllImportAttribute("shell32.dll")] //SHEmptyRecycleBin為一個API函數,可清除垃圾筒
private static extern int SHEmptyRecycleBin(IntPtr handle, string root, int flags);
private void button1_Click(object sender, EventArgs e)
{
SHEmptyRecycleBin(this.Handle, "", SHERB_NOCONFIRMATION + SHERB_NOPROGRESSUI + SHERB_NOSOUND);
}
沒有留言:
張貼留言