as me was blocked on the same issue from last 3-4 days n tried a lot of different attempts for the same but not a single one turned out to be successful.
But finally today i got the solution.
After making it double sure that all the permissions are set to WRITE.
USE string filepath = Server.MapPath("./Images/");
instead of
string filepath = Server.MapPath("~//Images//");
the main issue was while mapping a virtual path
it starts the path from site folder
so we need to map with "." instead of "~"
I have tried the same solution on 3 different projects for the same problem.
all of them started working very smoothly.
All the best..... :)
Please mark this as "ANSWER" if this helps u.
-------------------
Rohit Mahadik
If you are getting that error , then I can say that your application doesn't have a write permission on some directory [where your trying to save or write image].
For example, if you are trying to save the Image from the memory stream to the file system , you may get that error.
I also faced that error when I was using Infragistics charts control , the control was trying to create a temporary chart in ChartImages folder and my application was not given the write permission.
Please if you are using XP, make sure to add write permission for the aspnet account on that folder.
If you are using windows server (2003,2008) or Vista, make sure that add write permission for the Network service account.
Mellanie
Member
190 Points
89 Posts
Re: A generic error occurred in GDI+
Nov 13, 2009 06:59 AM|LINK
Of course that worked! Thanks for advice :)
hello.vickey
Member
34 Points
7 Posts
Re: A generic error occurred in GDI+
Feb 25, 2010 05:56 AM|LINK
@dacraka Completly Agree with you,one need to dispose the objects insted of carry them further... have a look a
private void SaveAsThumbNail(int thumb_height, int thumb_width, FileUpload FileUpldCntrl, string imgPath)
{
System.Drawing.Image myimage;
try
{
FileUpldCntrl.SaveAs(Server.MapPath(imgPath));
myimage = System.Drawing.Image.FromFile(Server.MapPath(imgPath));
System.Drawing.Bitmap source_bitmap = new System.Drawing.Bitmap(myimage);
myimage.Dispose();
System.Drawing.Bitmap thumb_bitmap = new System.Drawing.Bitmap(thumb_width, thumb_height);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumb_bitmap);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(System.Drawing.Brushes.White, 0, 0, thumb_width, thumb_height);
g.DrawImage(source_bitmap, 0, 0, thumb_width, thumb_height);
g.Dispose();
System.Drawing.Imaging.ImageCodecInfo[] Info = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders();
System.Drawing.Imaging.EncoderParameters Params = new System.Drawing.Imaging.EncoderParameters(1);
Params.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
thumb_bitmap.Save(Server.MapPath(imgPath), Info[1], Params);
}
catch (Exception ex)
{
CommonFunctions objcom = new CommonFunctions();
objcom.LogError(Convert.ToString(Page.Page), Convert.ToString(ex.TargetSite.Name),
ex.Message.ToString(), HttpContext.Current, ex);
}
}
hasibul2363
Member
60 Points
19 Posts
Re: A generic error occurred in GDI+
May 22, 2010 06:40 PM|LINK
This is only for read and write permision. Just enable write permision on your folder.
hopeful it will solve your problem.
MCC, MCPD(ASP.net)
http://hasibulhaque.com
rohitmahadik
Member
586 Points
123 Posts
Re: A generic error occurred in GDI+
Jul 08, 2010 10:09 AM|LINK
Hello Friends,
as me was blocked on the same issue from last 3-4 days n tried a lot of different attempts for the same but not a single one turned out to be successful.
But finally today i got the solution.
After making it double sure that all the permissions are set to WRITE.
USE string filepath = Server.MapPath("./Images/");
instead of
string filepath = Server.MapPath("~//Images//");
the main issue was while mapping a virtual path
it starts the path from site folder
so we need to map with "." instead of "~"
I have tried the same solution on 3 different projects for the same problem.
all of them started working very smoothly.
All the best..... :)
-------------------
Rohit Mahadik
savindra.ban...
Member
22 Points
13 Posts
Re: A generic error occurred in GDI+
Sep 15, 2011 06:12 AM|LINK
Hi,
If you are getting that error , then I can say that your application doesn't have a write permission on some directory [where your trying to save or write image].
For example, if you are trying to save the Image from the memory stream to the file system , you may get that error.
I also faced that error when I was using Infragistics charts control , the control was trying to create a temporary chart in ChartImages folder and my application was not given the write permission.
Please if you are using XP, make sure to add write permission for the aspnet account on that folder.
If you are using windows server (2003,2008) or Vista, make sure that add write permission for the Network service account.
Hope it help some one.
gdi+ memory bitmap sclaing drawimage resizing gdiplus