Drew
Drew

Reputation: 13398

C# generic error in GDI+ when saving an image

When I try to save an image using either System.Drawing.Image.Save(String) or System.Drawing.Bitmap.Save(String) an exception is throw indicating a generic error in GDI+. Searching the web and Stack Overflow shows that I should be making sure I don't close the stream the image came from, but in my case the image was downloaded from the internet through a 3rd party library and I have no control over the stream it was read from (if it was even read from a stream)

I've tried a few things such as copying the image, but I always get the same error. Any ideas on how to fix this?

Upvotes: 1

Views: 1213

Answers (2)

Nicole Calinoiu
Nicole Calinoiu

Reputation: 20992

Try using the Save(String, ImageFormat) overload. The image format inference doesn't appear to work particularly well.

Upvotes: 1

Babak Naffas
Babak Naffas

Reputation: 12561

I've had this in the past. Make sure you have write permissions to wherever you're saving the file.

Upvotes: 2

Related Questions