Click here to Skip to main content
15,917,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hye..my program is about, i check the checkbox and run the recycle bin program after i click the button, but i'm having the error when run the program. How do i actually solve that problem ?

thanks

What I have tried:

private void Button2_Click(object sender, EventArgs e)
       {

           checkBox1.Checked = SHEmptyRecycleBin(IntPtr.Zero, null, RecycleFlag.SHERB_NOSOUND | RecycleFlag.SHERB_NOCONFIRMATION);


       }
Posted
Updated 25-Jul-17 19:40pm
Comments
Atlapure Ambrish 26-Jul-17 3:35am    
Can you elaborate more on the error and on which line you are getting it? It is not clear from your description.
Asyraf Patt 26-Jul-17 9:02am    
original:
private void Button2_Click(object sender, EventArgs e)
{
SHEmptyRecycleBin(IntPtr.Zero, null, RecycleFlag.SHERB_NOSOUND | RecycleFlag.SHERB_NOCONFIRMATION);
}

above is my function, when i click the button, it will clean my dustbin. The code that i actually trying to do is, i need to tick the checkbox and click the button and then the dustbin wil clean up.

latest code:

private void Button2_Click(object sender, EventArgs e)
{

checkBox1.Checked = SHEmptyRecycleBin(IntPtr.Zero, null, RecycleFlag.SHERB_NOSOUND | RecycleFlag.SHERB_NOCONFIRMATION);

}

Question: how actually can i combine checkbox and button, to execute this program ?

Sorry mate for my unclear question.

1 solution

SHEmptyRecycleBin return integer (int) value


if successfully empty Recycle Bin then return 0
and if Recycle Bin already empty and you fire button click then return value like -2147418113

so, you need to change code accordingly true false for check box checked/unchecked
 
Share this answer
 
Comments
Asyraf Patt 26-Jul-17 2:15am    
im not clear, sorry mate.. im new in programming

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900