Question A generic error occurred in GDI+.

ALX

Well-known member
Joined
Nov 16, 2005
Messages
253
Location
Columbia, SC
Programming Experience
10+
I load a bitmap into a picturebox (p) using "Image.FromFile(filename.bmp)" after which I may or may not make changes to it. In case changes have been made, I try to save the bitmap back to disk by using
VB.NET:
 p.Image.Save("NameofBitmap.bmp")
This generates a generic GDI exception, and I presume it is because "The image was saved to the same file it was created from". Is there simple way around this?
 
I gave up that approach and have decided to save the modified bitmap to a different filename and at the end of the process, delete the original file and rename the new file to the original filename. When I tried to delete the original file, I got the error "Access denied: File is in use by another process". It always seems that I'm doing things in a way that the folks a Microsoft don't like. How do we inform Microsoft's software that we are finished with a file, and it's OK to delete, move or whatever ?
 
Back
Top