A generic error occurred in GDI+, JPEG Image to MemoryStream

前端 未结 30 1822
再見小時候
再見小時候 2020-11-22 06:47

This seems to be a bit of an infamous error all over the web. So much so that I have been unable to find an answer to my problem as my scenario doesn\'t fit. An exception ge

30条回答
  •  执笔经年
    2020-11-22 07:14

    My turn!

    using (System.Drawing.Image img = Bitmap.FromFile(fileName))
    {
          ... do some manipulation of img ...
          img.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
    }
    

    Got it on the .Save... because the using() is holding the file open, so I can't overwrite it. Maybe this will help someone in the future.

提交回复
热议问题