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

前端 未结 30 1490
再見小時候
再見小時候 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:18

    You'll also get this exception if you try to save to an invalid path or if there's a permissions issue.

    If you're not 100% sure that the file path is available and permissions are correct then try writing a to a text file. This takes just a few seconds to rule out what would be a very simple fix.

    var img = System.Drawing.Image.FromStream(incomingStream);
    
    // img.Save(path);
    System.IO.File.WriteAllText(path, "Testing valid path & permissions.");
    

    And don't forget to clean up your file.

提交回复
热议问题