I want delete a file but an error occured please help me.
==============================
The process cannot access the file 'D:\My Project\AzadUniv\New\12\GUI\Upload\NewsImage\5564868769930125853-Image' because it is being
used by another process.
==============================
string ImagePath = Server.MapPath(".")+"\\Upload\\NewsImage\\" + Utility.GenerateGUID() + "-Image";
if (fuImage.PostedFile != null)
{
fuImage.PostedFile.SaveAs(ImagePath);
fuImage.Dispose();
string d = Utility.GetThumbnailImage(ImagePath, 100, 100,true);
}
public static string GetThumbnailImage(string path,int x,int y,bool DeleteAfterSave)
{
Bitmap image = new Bitmap(x, y);
Graphics g = Graphics.FromImage(image);
System.Drawing.Image thumbnail =
System.Drawing.Image.FromFile(path);
g.DrawImage(thumbnail, 0, 0, x, y);
string NewPath = path +"-small.jpg";
image.Save(NewPath, ImageFormat.Jpeg);
g.Dispose();
image.Dispose();
if (DeleteAfterSave == true)
{
System.IO.File.Delete(path);
}
return path;
}