我收到这个错误
The process cannot access the file '..\Images\Temp\6574_1212665562989_1419270107_30610848_6661938_n.jpg' because it is being used by another process.
当我尝试这个时:
try
{
var file = Request.Files["FileProfilePicture"];
file.SaveAs(Server.MapPath("~/Images/Temp/" + file.FileName));
Bitmap imageOrj = new Bitmap(System.Web.HttpContext.Current.Server.MapPath("~/Images/Temp/" + file.FileName));
Image imageBig = ResizeImage.Resize(imageOrj, 100, 100);
imageBig.Save(System.Web.HttpContext.Current.Server.MapPath("~/Images/ProfilePicBig/" + file.FileName));
Image imageSmall = ResizeImage.Resize(imageOrj, 50, 50);
imageSmall.Save(System.Web.HttpContext.Current.Server.MapPath("~/Images/ProfilePicSmall/" + file.FileName));
string[] files = System.IO.Directory.GetFiles(Server.MapPath("~/Images/Temp/"));
foreach (string pathFile in files)
{
System.IO.File.Delete(pathFile);
}
return RedirectToAction("Index", "Author");
}
catch (Exception e)
{
ModelState.AddModelError("", "Kullanıcı bilgileri güncellenirken bir hata oluştu. Lütfen daha sonra tekrar deneyin." + e.Message);
}
我该如何解决。或者另一种将图像保存为临时文件的更好方法。我应该将文件保存在临时文件夹中吗?
谢谢