Introduction
Providing solution to very common issue "A generic error occurred in GDI+." while working with ASP.Net MVC C# application. In this application, I was writing code to save image in Png format. Sometimes, we don't have any exact idea about issue, then we can wastage our precious development time, to overcome this issue, I come up here with to resolve this issue.Problem Where Encountered
img1.Save(Server.MapPath("/Upload/test.png", System.Drawing.Imaging.ImageFormat.Png);
Few other more reasons to arise issue A generic error occurred in GDI+
- This error can also comes out while upload folder don't have permissions to save image.
- If we are creating image from bytes and bytes are locked then this also throws relevant exception.
- Check for the same file/image exists in the same folder.
- Always use dispose method to deallocate memory while image/file generating from bytes array.
Fig: A generic error occurred in GDI
Post A Comment:
0 comments: