how File.Delete() file temp.jpg with process A if locked by process B. how close handles file temp.jpg
IOExceoption: The process cannot access the file Because it is being used by another process
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;
}