Honestly, what works with GDI + in ASP.Net? It works so mysteriously, and the error descriptions are rather mysterious: A common mistake in GDI +.
Oh, thank you very much, now I know for sure what went wrong ... no.
Take a look at the code causing the error, and maybe you can help me?
var fileStream = fuImage.FileContent;
var imageStream = new MemoryStream();
imageStream.SetLength(fileStream.Length);
fileStream.Read(imageStream.GetBuffer(), 0, (int)fileStream.Length);
imageStream.Flush();
fileStream.Close();
using (var image = System.Drawing.Image.FromStream(imageStream))
{
using (Bitmap bmp = new Bitmap(image.Width, image.Height))
{
using (Graphics gr = Graphics.FromImage(bmp))
{
gr.DrawImage(image, 0, 0);
bmp.Save(path);
}
}
}
This is a really simplified version of my code, but it still causes an error. fuImage is a control FileUpload(.NET Web Forms).
If you get this error, make sure that there is a full path to where you are going to save the file ... or you may receive this general error message.