Загрузка файла проверка на вирусы
я хочу загрузить файл проверки на вирусы
Что я уже пробовал:
public void scanfile() { string c; bool IsValid = true; //foreach (FileInfo file in fileuploadExcel.Unload) //{ try { //do av check here Process myProcess = new Process(); FileUpload1.SaveAs(Server.MapPath("~\\uploadphoto\\") + FileUpload1.FileName); //address of command line virus scan exe myProcess.StartInfo.FileName = Server.MapPath("~\\AVG10\\avgscanx.exe"); string path = '"' + "" + Server.MapPath("~\\uploadphoto\\") + "" + FileUpload1.FileName + "" + '"'; string report = '"' + "" + Server.MapPath("~\\uploadphoto\\Report.txt") + "" + '"'; string myprocarg = "/SCAN=" + path + " /REPORT=" + report; //" /REPORT=C:\\Upload\\Temp\\Report.txt"; myProcess.StartInfo.Arguments = myprocarg; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.RedirectStandardOutput = true; myProcess.Start(); myProcess.WaitForExit(); //wait for the scan to complete //add some time for report to be written to file int j = 0; int y = 0; for (j = 0; j <= 1000000; j++) { y = y + 1; } //Get a StreamReader class that can be used to read the file StreamReader objStreamReader = default(StreamReader); objStreamReader = File.OpenText(Server.MapPath("~\\VirusScan\\Report.txt")); String reportVerbose = objStreamReader.ReadToEnd().Trim(); if (reportVerbose.Length > 0 && !reportVerbose.Contains("Found infections : 0")) { IsValid = false; File.Delete(Server.MapPath("~\\VirusScan\\temp\\") + "" + FileUpload1.FileName); } objStreamReader.Close(); if (IsValid) { try { if (!Directory.Exists(Server.MapPath("~/DataFiles/"))) Directory.CreateDirectory(Server.MapPath("~/DataFiles/")); if (!File.Exists(Server.MapPath("~/DataFiles/" + System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName)))) { FileUpload1.SaveAs(Server.MapPath("~/DataFiles/") + FileUpload1.FileName); } else { try { File.Delete(Server.MapPath("~/DataFiles/" + System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName))); FileUpload1.SaveAs(Server.MapPath("~/DataFiles/") + FileUpload1.FileName); } catch (System.IO.IOException) { } } } catch (System.IO.IOException) { } } } catch (System.IO.IOException) { }