473,387 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Error: A Generic Error occurred in GDI+

Hi Dear,

Here I am trying to upload a photo.

Expand|Select|Wrap|Line Numbers
  1. protected void LoadImage()        {
  2.             string UserName = Session["UserName"].ToString();
  3.  
  4.             byte[] Data = Profile.GetImageData(UserName); //Stmt Correct where profile is class
  5.  
  6.             if (Data != null)
  7.             {
  8.                 MemoryStream stream = new MemoryStream(Data);
  9.  
  10.                 Bitmap bitmap = null;
  11.                 bitmap = new Bitmap(stream);
  12.  
  13.                 bitmap.Save(Server.MapPath(@"~\UserPhoto.bmp"), system.Drawing.Imaging.ImageFormat.Bmp); 
  14.                 //Error:A Generic   Error occurred in GDI+            
  15.                 bitmap.Dispose();
  16.                 imgPhoto.ImageUrl = @"~\UserPhoto.bmp";            }     }

I have created virtual directory and trying to open it directly from browser
Dec 29 '09 #1
3 3298
sanjib65
102 100+
I think the problem occurs while opening up your virtual directory as you have earlier used Server.MapPath();
Dec 29 '09 #2
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Dec 29 '09 #3
tlhintoq
3,525 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. bitmap.Save(Server.MapPath(@"~\UserPhoto.bmp"), system.Drawing.Imaging.ImageFormat.Bmp);
I don't see any error checking.
What if you don't have write permissions to the directory?
What if an image of that name already exists in the directory?
Are you sure the MapPath function with that string literal is valid and not something like: Server\Userfolder\~\UserPhoto.bmp
Dec 29 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Michael Kennedy [UB] | last post by:
Hi Everyone, I have this multithreaded C# windows forms application which does a lot of image processing. Occasionally, I get the following error: A generic error occurred in GDI+....
2
by: Barry | last post by:
Hi Does anyone know why i am getting the following error message (line 64) , if i change to objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg) i do not get this error Exception...
2
by: Alphonse Giambrone | last post by:
I am currently reading 'Programming The Web with Visual Basic .NET' and have so far found it to be excellent. Downloaded all the code from Apress and working in chapter 4, I get the error shown...
2
by: Tim::.. | last post by:
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...
3
by: Ger | last post by:
I have a form with a panel (Panel1) in which I dynamically create picturebox controls. Works like a dream with static pictures, but not when the picturebox.image is an animated gif. GDI+ throws the...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
0
by: manini | last post by:
Hello Everyone I m getting the generic GDI + error,Please help me to resolve this error ************** Exception Text ************** System.Runtime.InteropServices.ExternalException: A generic...
0
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have a bitmap which I have retreived through the WebBrowser DrawToBitmap method into a Bitmap. When I try to save the bitmap I get "ExternalException occurred A generic error occurred in...
7
by: j4richard | last post by:
Help please, I am getting this "Unhandled Exception has occurred in your application" " A Generic error occurred in GDI+" See the end of this message for details on...
1
by: Jeff | last post by:
hi asp.net 2.0 I'm experimenting with GDI+ in asp.net and get an "A generic error occurred in GDI+." exception. Below is my code, I've marked a line with "<<<<-- here". It's here the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.