Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to delete an Image used by a PictureBox,I tried:

C#
PictureBox1.Image.Dispose();
PictureBox1.Image = null;


And then tried to delete it,but code didn't work.Please Help
Posted
Comments
ajax_vn 25-Feb-12 11:51am    
help me, How can I make sql server database into software
ajax_vn 25-Feb-12 11:55am    
help me: when installing the management software, often times it built the database into it, so how do I do that? thank you!
mmm3743 25-Feb-12 11:57am    
do you mean connecting your database with your application?

1 solution

The Dispose() method called on Image property of PictureBox1 disposes (deletes / releases memory held by the image), hence there is no need to delete the image again.

The following link may be helpful in this regard

http://stackoverflow.com/questions/2808753/right-way-to-dispose-image-bitmap-and-picturebox[^]
 
Share this answer
 
Comments
mmm3743 25-Feb-12 12:06pm    
Thanks,this helped,for everyone who need an awnser,the awnser is:
public static Bitmap LoadBitmap(string path) {
using (Bitmap original = new Bitmap(path))
{
return new Bitmap(original);
}
}
ProEnggSoft 25-Feb-12 12:18pm    
Thank you.

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