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
Please review the code, help me to find where I am doing wrong. I really appreciate your help to solve this issue....
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();
{
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();
}