This is a migrated thread and some comments may be shown as answers.

"A generic error occurred in GDI+"

1 Answer 374 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Shreya
Top achievements
Rank 1
Shreya asked on 22 May 2012, 12:36 PM
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....

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 24 May 2012, 02:11 PM
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.
Tags
ImageEditor
Asked by
Shreya
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or