A generic error has occurred in GDI+
- by sysigy
I know this has been asked a million times but I think I need to make it a million and one.
I am getting "A generic error has occurred in GDI+" when trying to save a new bitmap.
I have completely stripped down to the most basic lines of code and I still get the error with the following method:
public class HomeController : Controller
{
public ActionResult Index()
{
return this.View();
}
public void CreatePicture()
{
try
{
// THIS WORKS
System.IO.File.Copy("C:\\copyTest.bmp", "C:\\test folder\\copyTest2.bmp");
// THIS WORKS
System.IO.File.Delete("C:\\test folder\\deleteTest.bmp");
using (Bitmap newBitmap = new Bitmap(120, 120))
{
// THIS FAILS
newBitmap.Save("C:\\test folder\\test.bmp", ImageFormat.Bmp);
}
}
catch (Exception ex)
{
throw ex;
}
}
}
The code is called from an html link on a blank page within an MVC 3.0 website using anonymous login.
View:
@Html.ActionLink("Create Picture", "CreatePicture", "Home", new { })
I have checked the folder permissions of "test folder" and have given full access to the following:
ASPNET
NETWORK SERVICE
IUSR
I still get the error... what have I missed / done wrong ?