GURU with Images

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!
 
D

Daryl

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!!!
 
K

Kevin Spencer

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!!!
 
D

Daryl

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
 
K

Kevin Spencer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top