By Recapture image occur error "The process cannot access the file because its used by another process."
my code is below i try to delete existing file but not successed.
- [WebMethod()]
- public static bool SaveCapturedImage(string data)
- {
- string fileName = DateTime.Now.ToString("dd-MM-yy hh-mm");
- //string fileName2 = DateTime.Now.ToString("dd-MM-yy hh-mm");
- //Convert Base64 Encoded string to Byte Array.
- //if (File.Exists(fileName2))
- //{
- // File.Delete(fileName2);
- //}
- //else
- //{
- byte[] imageBytes = Convert.FromBase64String(data.Split(',')[1]);
- //Save the Byte Array as Image File.
- string filePath = HttpContext.Current.Server.MapPath(string.Format("~/CapturedImage/{0}.jpg", fileName));
- File.WriteAllBytes(filePath, imageBytes);
- return true;
- //}

Replies
Know the answer? Post it — somebody with the same question will find it here.