GURU with Images

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi can someone please tell me why I keep getting the following error and how I might fix it!

...::ERROR::..
Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.

The line causing the problem is outputImage.Save, but I really don't understand why, it works fine if I save the jpeg image in the wwwroot folder or even wwwroot/images but as soon as I make the folder structure any deeper I get the above error. Has anyone ever experience this before??? Can some please tell me how I fix the problem!!!



...::CODE::..
System.Drawing.Bitmap outputImage = new System.Drawing.Bitmap(origBitmap, newWidth, newHeight);
outputImage.Save(Server.MapPath(basePath + System.IO.Path.GetFileName(_FileName.Value)),System.Drawing.Imaging.ImageFormat.Jpeg);

statusinfo.InnerHtml = "Uploaded " + Server.MapPath(basePath + System.IO.Path.GetFileName(_FileName.Value));


Thanks for any help!
 
One thing to note is that the current image save sometimes ges back to
write the number of bytes. If you use the utput stream this will fail.
Create a memory stream write to that and then copy the memory stream too the
output buffer.

Hope that helps
Daryl

Tim::.. said:
Hi can someone please tell me why I keep getting the following error and how I might fix it!

..::ERROR::..
Exception Details: System.Runtime.InteropServices.ExternalException: A
generic error occurred in GDI+.
The line causing the problem is outputImage.Save, but I really don't
understand why, it works fine if I save the jpeg image in the wwwroot folder
or even wwwroot/images but as soon as I make the folder structure any deeper
I get the above error. Has anyone ever experience this before??? Can some
please tell me how I fix the problem!!!
 
The "generic error" message is very frustrating in GDI+. It is a catch-all
message which is about all you're going to get from GDI+. From your
description, it sounds like you may have a permissions issue. Have you
checked the folder permissions for the folders you are trying to write to?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Tim::.. said:
Hi can someone please tell me why I keep getting the following error and how I might fix it!

..::ERROR::..
Exception Details: System.Runtime.InteropServices.ExternalException: A
generic error occurred in GDI+.
The line causing the problem is outputImage.Save, but I really don't
understand why, it works fine if I save the jpeg image in the wwwroot folder
or even wwwroot/images but as soon as I make the folder structure any deeper
I get the above error. Has anyone ever experience this before??? Can some
please tell me how I fix the problem!!!
 
Actually from your code

basePath +
System.IO.Path.GetFileName(_FileName.Value));

Don't you need to put the / in between the basePath and filename.

Daryl
 
I just noticed that he's using Server.MapPath() as part of his code. It is
possible that these "deeper" folders are not part of the folder structure of
his current ASP.Net app, which would cause an error when using this method.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top