I am tracking an unpleasant problem, and I narrowed down the problem and realized that this happens when I deal with the Image instance returned by Image.FromStream (). I have a utility method that returns an instance of an image from a file using Stream, so I don't have an open file descriptor. Here is this useful method (nothing special):
public static Image ImageFromFileReleaseHandle(string filename) { using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { return Image.FromStream(fs); } }
When I try to save an image loaded from the above method, I get InteropServices.ExternalException "A general error occurred in GDI +". The following code example will demonstrate this:
private void button6_Click(object sender, EventArgs e) { var filename = @"D:\My Documents\My Pictures\2010-03-27 hangover hike.jpg";
If I upload an image using Image.FromFile (), I can save without problems:
private void button6_Click(object sender, EventArgs e) { var filename = @"D:\My Documents\My Pictures\2010-03-27 hangover hike.jpg";
I can not come up with any additional information that would be useful. I hope my code examples are simple enough so you can clearly see the problem.
Thanks Steve
source share