how to dispose the bitmap data type in c# windows application

Aug 29 2009 3:12 AM

Hi,
I created one bitmap datatype to store image like this
img1 =
new Bitmap("C:\\pic\\img.jpg");
then i did some image comparison with other image after that i want to store the another image in the same path C:\\pic\\img.jpg
like this
this
.pictureBox1.Image.Save("C:\\pic\\img.jpg");
but the first image is locked it's not storing the new image which i am trying store from the picturebox1
even
File.Delete("C:\\pic\\img.jpg"); is also not working the old image has not deleted because the bitmap image is locked
i saw some article in net the bitmap images will be locked untill they have disposed.
so plese tell me the code to disopose the bitmap images

Answers (1)