如果被进程 B 锁定,File.Delete() 文件 temp.jpg 如何与进程 A 一起使用。close 如何处理文件 temp.jpg
IOExceoption:进程无法访问该文件,因为它正被另一个进程使用
protected void ButtonJcrop_Click(object sender, EventArgs e)
{
MembershipUser user = Membership.GetUser();
String tempPath = Server.MapPath("..") + @"\Users\" + user.ProviderUserKey.ToString() + @"\temp.gif";
System.Drawing.Image img = System.Drawing.Image.FromFile(tempPath);
Bitmap bmpCropped = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(bmpCropped);
Rectangle rectDestination = new Rectangle(0, 0, bmpCropped.Width, bmpCropped.Height);
Rectangle rectCropArea = new Rectangle(Int32.Parse(hfX.Value), Int32.Parse(hfY.Value), Int32.Parse(hfWidth.Value), Int32.Parse(hfHeight.Value));
g.DrawImage(img, rectDestination, rectCropArea, GraphicsUnit.Pixel);
String mapPath = @"\Users\" + user.ProviderUserKey.ToString() + @"\" + user.ProviderUserKey.ToString() + ".gif";
bmpCropped.Save(Server.MapPath("..") + mapPath);
// bmpCropped.Save(Server.MapPath("..") + @"\Images\thumbs\CroppedImages\" + Session["WorkingImage"]);
imCropped.ImageUrl = Request.ApplicationPath + mapPath;
**File.Delete(tempPath);**
PlaceHolderImCropped.Visible = true;
}