I will attach a documented demo app to illustrate the problem I am having. Each of these cases work
I can successfully create a PNG file based on a specified control on the form. I can them load the PNG into a picture box.
Repeatedly create the PNG, with the same file name but not displaying it
Displaying Pic2, but then creating Pic1
What does not work
Displaying the image of Pic1, then trying to overwrite PNG1 with the same file name. It does not matter if the Picture in the picture box has been replaced or not.
It gives the error "System.Runtime.InteropServices.ExternalException: 'A generic error occurred in GDI+.'"
If I stop and rerun it, no problem until I load an image that I try to overwrite. It seems like the file is being locked as soon as I read it, which prevents me from writing over it. In any case you can see for your self with the code.
Nobody wants to have to download a ZIP file, extract it, open a solution and then trawl through it hoping to find the relevant part. That should be a last resort. Post the relevant code and ONLY the relevant code directly so that we can just read it and then copy and paste it if required.
Also, the size of your attachment strongly suggests that it contains binary files, which is against site rules. If you are going to attach a zipped solution, ALWAYS delete any bin and obj folders first.