A generic error occurred in GDI+

Thread is closed for posting
2 posts, 0 answers
  1. Bader
    Bader avatar
    215 posts
    Member since:
    Aug 2008

    Posted 01 Jan 2012 Link to this post


    I'm getting the "A generic error occurred in GDI+" error message while using the following code:

    using (System.Drawing.Image originalImage = System.Drawing.Image.FromStream(upload.UploadedFiles[0].InputStream))
    //Create empty bitmap image of original size
    Bitmap tempBmp = new Bitmap(originalImage.Width, originalImage.Height);
    Graphics g = Graphics.FromImage(tempBmp);
    //draw the original image on tempBmp
    g.DrawImage(originalImage, 0, 0, originalImage.Width, originalImage.Height);
    //dispose originalImage and Graphics so the file is now free
    Response.ContentType = "image/jpeg";
    //Save the image file to original location
    tempBmp.Save(Server.MapPath("~Products/General/Imgs/Menus/" + parentSysName + "/" + productID.ToString() + "_" + upload.UploadedFiles[0].FileName), System.Drawing.Imaging.ImageFormat.Jpeg);

    Can you please help me how to solve this problem?
    By the way, I looked on the internet, but I didn't found anything.


  2. Bader
    Bader avatar
    215 posts
    Member since:
    Aug 2008

    Posted 12 Jan 2012 Link to this post

    Hi All,

    My mistake,
    Please make sure of the path,

  3. DevCraft R3 2016 release webinar banner
Back to Top