i want to capture image again if image not proper in c# using webcam into web application. but below error is generate while recapture image. how to solve this error.
Additional information: The process cannot access the file 'C:\VisiterManagment\VisiterManagment\CapturedImage\Image.jpg' because it is being used by another process.
i am also deleting existing file using file exist but not working kindly please help me.
here is my c# code
- string FileName = Path.GetFileName("~/CapturedImage/Image.jpg");
- if (File.Exists(Path.GetFileName(FileName)))
- {
- File.Delete(FileName);
- }
- if (!this.IsPostBack)
- {
- if (Request.InputStream.Length > 0)
- {
- using (StreamReader myreader = new StreamReader(Request.InputStream))
- {
- string myhexString = Server.UrlEncode(myreader.ReadToEnd());
-
- string myimagePath = string.Format("~/CapturedImage/Image.jpg");
- File.WriteAllBytes(Server.MapPath(myimagePath), ConvertHexToBytes(myhexString));
- Session["CapturedImage"] = ResolveUrl(myimagePath);
- }
- }
- }