"A generic error occurred in GDI+"

2 posts, 0 answers
  1. Shreya
    Shreya avatar
    1 posts
    Member since:
    May 2012

    Posted 22 May 2012 Link to this post

    Hello Team,

    I am using Telerik Image Editor. I want to save and overwrite file on custom path using RadImageEditor_ImageSaving Server side event.

     when I modify image and try to save it on same path, I am getting error "A generic error occurred in GDI+"

     Please Note: I want to maintain only two versions of file 1) Original file 2) Updated file

      protected void RadImageEditor1_ImageSaving(object sender, ImageEditorSavingEventArgs args)
            {


               
                var context = new EBABBLEEntities();


                Account Lo_Account = (from acc in context.Accounts where acc.Id == cls_Session.User.Id select acc).FirstOrDefault();
                System.Drawing.Image newImage = args.Image.Image;


                string filename = Path.GetFileNameWithoutExtension(ImageURL);
                int indexer = filename.IndexOf("_Edited");


                if (indexer != -1)
                {
                    newImage.Save(Server.MapPath("~" + Lo_Account.files_path + "/My_DigiGLUS/") + filename.Substring(0, (filename.Length) - 7) + "_Edited" + Path.GetExtension(ImageURL));


                }
                else
                {
                    newImage.Save(Server.MapPath("~" + Lo_Account.files_path + "/My_DigiGLUS/") + Path.GetFileNameWithoutExtension(ImageURL) + "_Edited" + Path.GetExtension(ImageURL));
                }


              
                args.Cancel = true;
                DigiId = Convert.ToInt32(Request.QueryString["digigluId"].ToString());
                DigiGLUs Editdigiglu = (from digi in context.DigiGLUs where digi.Id == DigiId select digi).FirstOrDefault();


                if (indexer != -1)
                {
                    Editdigiglu.NewImageName = filename.Substring(0, (filename.Length) -7) + "_Edited" + Path.GetExtension(ImageURL);




                }
                else
                {
                    Editdigiglu.NewImageName = Path.GetFileNameWithoutExtension(ImageURL) + "_Edited" + Path.GetExtension(ImageURL);
                }




                context.SaveChanges();
    }
    Please review the code, help me to find where I am doing wrong. I really appreciate your help to solve this issue....
  2. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 24 May 2012 Link to this post

    Hello,

    I believe that the following forum thread could be helpful for your to resolve this generic ASP.NET error:

    http://stackoverflow.com/questions/1044085/a-generic-error-occurred-in-gdi.

    Kind regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top