I am updating the same image in .Net Core MVC I am getting this error:
Here is my code: public IActionResult UpdateProduct(IFormFile product_image, Product prd)
{
string ImagePath = Path.Combine(_env.WebRootPath,”ProductImages”,product_image.FileName);
FileStream fs = new FileStream(ImagePath, FileMode.Create);
product_image.CopyTo(fs);
prd.product_image = product_image.FileName;
_manicontext.tbl_product.Update(prd);
_manicontext.SaveChanges();
return RedirectToAction("FetchProduct");
}
How to solve this error
System.IO.IOException: ‘The process cannot access the file ‘red-kalenji-8771124.jpg’ because it is being used by another process.’
Sarfaraz Qadir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.