I want to save an image after some changes in image.
but I am getting an error while calling .Save() function.
var tempapth = Server.MapPath("..//Images//Temp//" + btnfile.FileName);
btnfile.SaveAs(tempapth);
using (var fileStream = File.OpenRead(tempapth))
{
var ms = new MemoryStream();
fileStream.CopyTo(ms);
ms.Seek(0, SeekOrigin.Begin);
System.Drawing.Image img1 = System.Drawing.Image.FromStream(ms);
fileStream.Close();
var bmp1 = img1.GetThumbnailImage(100, 150, null, IntPtr.Zero);
bmp1.Save(path);
}
bmp1.save(path);
give an error
A generic error occurred in GDI+
EDIT
The OP changed the question after I wrote this reply. Previously, there was also a
pathvariable declared, which contained a path name (but no file name).In the first version of your code, you had a path name without a file name (
Server.MapPath("..//Images//Category//" + catid + "//");). To save, you need to add a file name, too, like: