C# Free Image file from use -


I have a temporary image file with which I

  bitmap-capped emg = (bitmap) ) Open Image.FromFile ("Item / Item.bmp");   

And because it's temporary I want to replace it with another image for another use, but the program is still using that image and I can not do anything.

How to go let's go from image to replace?

I had a similar problem and could not use it because the file was overwritten by some asynchronous code it was done. I resolved this issue by copying the bitmap and filling the original one:

  bitmap tmpBmp = new bitmap (full filename); Bitmap image = new bitmap (tmpbmp); TmpBmp.Dispose ();    

Comments