i am suffered from this problem from last 4 days and still blank regarding this error.
bellow is the function for uploading the image in three different folder large,view and thumb.
this function well performed when saving a new image but when ever tried to update the image this function will save the large image but gives error regarding view and thumb. if there is any solution plz help me. its take to much time of mine :(
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 if this helps u.
-------------------
Rohit Mahadik
None
0 Points
2 Posts
A generic error occurred in GDI+.
May 27, 2009 06:19 AM|vipinsolanki|LINK
bellow is the function for uploading the image in three different folder large,view and thumb.
private void upload_file_large_thumb(String thumb_url, String large, String view, FileUpload fileuploader) { if (Session["folder"].ToString() != "") { String file_name = ""; #region save large Image //save large Image String basepath = "../../images/" + Session["folder"].ToString() + "/"; basepath = Server.MapPath(basepath); file_name = large; //first delete maybe file try { if (File.Exists(basepath + file_name)) File.Delete(basepath + file_name); } catch { } fileuploader.SaveAs(basepath + file_name); fileuploader.Dispose(); System.Drawing.Image.FromStream(fileuploader.PostedFile.InputStream).Dispose(); #endregion #region save view //save view file_name = view; System.Drawing.Image view_image = System.Drawing.Image.FromStream(fileuploader.PostedFile.InputStream); view_image = ResizeImage.resizeImage(view_image, 710); basepath = "../../images/" + Session["folder"].ToString() + "/view/"; basepath = Server.MapPath(basepath); //first delete may be file try { if (File.Exists(basepath + file_name)) File.Delete(basepath + file_name); } catch { } //view_image.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX); view_image.Save(basepath + file_name); view_image.Dispose(); System.Drawing.Image.FromStream(fileuploader.PostedFile.InputStream).Dispose(); view_image = null; GC.Collect(); #endregion #region save thumbnail //save thumbnail file_name = thumb_url; System.Drawing.Image thumb = System.Drawing.Image.FromStream(fileuploader.PostedFile.InputStream); thumb = ResizeImage.resizeImage(thumb, 100); basepath = "../../images/" + Session["folder"].ToString() + "/thumbs/"; basepath = Server.MapPath(basepath); //first delete may be file try { if (File.Exists(basepath + file_name)) File.Delete(basepath + file_name); } catch { } //thumb.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX); thumb.Save(basepath + file_name); thumb.Dispose(); System.Drawing.Image.FromStream(fileuploader.PostedFile.InputStream).Dispose(); thumb = null; GC.Collect(); #endregion fileuploader.PostedFile.InputStream.Close(); } }
this function well performed when saving a new image but when ever tried to update the image this function will save the large image but gives error regarding view and thumb. if there is any solution plz help me. its take to much time of mine :(
A generic error occurred in GDI+
Member
200 Points
60 Posts
Re: A generic error occurred in GDI+.
May 27, 2009 08:11 AM|shashankmishra|LINK
Use view_image.Dispose() before view_image.RotateFlip
and create a new image (instead of view_image) from stream rather than using the same image object again.
Look on to this:
http://forums.asp.net/p/1378591/2906942.aspx
--
Shashank
BeClasp Consulting
None
0 Points
2 Posts
Re: A generic error occurred in GDI+.
May 27, 2009 08:18 AM|vipinsolanki|LINK
Member
363 Points
123 Posts
Re: A generic error occurred in GDI+.
Jul 08, 2010 06:24 AM|rohitmahadik|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