Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Error:A Generic Error occurred in GDI+

Error:A Generic Error occurred in GDI+

Scheduled Pinned Locked Moved ASP.NET
graphicswinformssysadminhelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    Udayaraju
    wrote on last edited by
    #1

    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

    W A 2 Replies Last reply
    0
    • U Udayaraju

      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

      W Offline
      W Offline
      www Developerof NET
      wrote on last edited by
      #2

      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

      U 1 Reply Last reply
      0
      • U Udayaraju

        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

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        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. :-D

        Abhishek 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

        U 1 Reply Last reply
        0
        • W www Developerof 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

          U Offline
          U Offline
          Udayaraju
          wrote on last edited by
          #4

          Permissions?? in which Way.. I have tried giving all READ and WRITE permissions in Virtual Directory but it doesn't solve any problem

          1 Reply Last reply
          0
          • A Abhishek Sur

            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. :-D

            Abhishek 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

            U Offline
            U Offline
            Udayaraju
            wrote on last edited by
            #5

            Hi abishek, Thanq for your Answer.. I have checked all the Permissions IIS-DefaultWebSite-MyProj-Rightclick-Properties. Tab Virtual Directory and I have checked READ and WRITE Permissions..??? Still it doesnt solve..

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups