This error occurs when performing the image saving function, But when saving a photo, the photo may be occur access permission error, so the solution is to create a copy of the photo to handle
Solution:
Solution:
using (Image img = Image.FromFile("path")) // using image
{
using (Bitmap bmp = new Bitmap(img)) // create new bitmap image from original image
{
// Work with bmp
}
}
Solution on stackoverflow:
const string i1Path = @"c:\my\i1.jpg"; // The path of the photo will be backed up
const string i2Path = @"c:\my\i2.jpg"; // new path for new image
var i = Image.FromFile(i1Path); // get image
var i2 = new Bitmap(i); // create new image
i2.Save(i2Path, ImageFormat.Jpeg); // save new image
Reference link : StackOverflow
Post a Comment