Error:A Generic Error occurred in GDI+
-
Hi Dear, Here I am trying to upload a photo. protected void LoadImage() { string UserName = Session["UserName"].ToString(); byte[] Data = Profile.GetImageData(UserName); //Stmt Correct where profile is class if (Data != null) { MemoryStream stream = new MemoryStream(Data); Bitmap bitmap = null; bitmap = new Bitmap(stream); bitmap.Save(Server.MapPath(@"~\UserPhoto.bmp"), system.Drawing.Imaging.ImageFormat.Bmp); //Error:A Generic Error occurred in GDI+ bitmap.Dispose(); imgPhoto.ImageUrl = @"~\UserPhoto.bmp"; } } I have created virtual directory and trying to open it directly from browser
-
Hi Dear, Here I am trying to upload a photo. protected void LoadImage() { string UserName = Session["UserName"].ToString(); byte[] Data = Profile.GetImageData(UserName); //Stmt Correct where profile is class if (Data != null) { MemoryStream stream = new MemoryStream(Data); Bitmap bitmap = null; bitmap = new Bitmap(stream); bitmap.Save(Server.MapPath(@"~\UserPhoto.bmp"), system.Drawing.Imaging.ImageFormat.Bmp); //Error:A Generic Error occurred in GDI+ bitmap.Dispose(); imgPhoto.ImageUrl = @"~\UserPhoto.bmp"; } } I have created virtual directory and trying to open it directly from browser
This usually happens when you don`t have write permissions on your application folder. Try giving the permissions.
When you fail to plan, you are planning to fail.
modified on Tuesday, December 29, 2009 7:19 AM
-
Hi Dear, Here I am trying to upload a photo. protected void LoadImage() { string UserName = Session["UserName"].ToString(); byte[] Data = Profile.GetImageData(UserName); //Stmt Correct where profile is class if (Data != null) { MemoryStream stream = new MemoryStream(Data); Bitmap bitmap = null; bitmap = new Bitmap(stream); bitmap.Save(Server.MapPath(@"~\UserPhoto.bmp"), system.Drawing.Imaging.ImageFormat.Bmp); //Error:A Generic Error occurred in GDI+ bitmap.Dispose(); imgPhoto.ImageUrl = @"~\UserPhoto.bmp"; } } I have created virtual directory and trying to open it directly from browser
First of all it is better to write
Server.MapPath("~/userPhoto.bmp")
always use / to refer virtual path correctly (Even though with Server.MapPath it doesnt matter. Seriously, there must be some problem writing in the folder where you are writing. As you are writing in the virtual directly directly check whether ASPNET_WP or IIS_WPG has write permission to the virtual directory. :-DAbhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Windows7 API Code Pack
Simplify Code Using NDepend
Basics of Bing Search API using .NET -
This usually happens when you don`t have write permissions on your application folder. Try giving the permissions.
When you fail to plan, you are planning to fail.
modified on Tuesday, December 29, 2009 7:19 AM
-
First of all it is better to write
Server.MapPath("~/userPhoto.bmp")
always use / to refer virtual path correctly (Even though with Server.MapPath it doesnt matter. Seriously, there must be some problem writing in the folder where you are writing. As you are writing in the virtual directly directly check whether ASPNET_WP or IIS_WPG has write permission to the virtual directory. :-DAbhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Windows7 API Code Pack
Simplify Code Using NDepend
Basics of Bing Search API using .NET