Rajagopalan R V

Rajagopalan R V

  • NA
  • 336
  • 68.5k

Virus Scanning Code Not Working Properly in ASP.NET 4.0 C#

Apr 10 2015 7:46 AM
//do av check here
  Process myProcess = new Process();
  //address of command line virus scan exe
  myProcess.StartInfo.FileName = "C:\\Program Files\\Symantec\\Symantec Endpoint Protection\\SymCorpUI.exe";
 
  string myprocarg = "/SCAN=" + fileNames + " /REPORT=C:\\Upload\\Temp\\Report.txt";
  myProcess.StartInfo.Arguments = myprocarg;
  myProcess.StartInfo.UseShellExecute = false;
  myProcess.StartInfo.RedirectStandardInput = true;
  myProcess.StartInfo.RedirectStandardOutput = true;
  myProcess.StartInfo.RedirectStandardError = true;
  myProcess.Start();
  StreamWriter inputWriter = myProcess.StandardInput;
  StreamReader outputReader = myProcess.StandardOutput;
  StreamReader errorReader = myProcess.StandardError;
 
  myProcess.WaitForExit();
  myProcess.Close();
 
  //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;
  }
 
  bool IsClean = true;
 
  //Get a StreamReader class that can be used to read the file
  StreamReader objStreamReader = default(StreamReader);
  objStreamReader = File.OpenText("C:\\Upload\\Temp\\Report.txt");
  if (!objStreamReader.ReadToEnd().Contains("Found infections  :  0"))
  {
  IsClean = false;
  File.Delete(filepath + "\\" + fileNames);
  }
  objStreamReader.Close();
 
   if (IsClean)
  {
 
  }
 else
  {

  }
  catch (Exception)
  {
  bool IsClean = true;
  Msgbox.DisplayAJAXMessage(this,"Some Error While Attaching Your File");
  IsClean = false;
  File.Delete(filepath + "\\" + fileNames);
  }
  }
 


Hi Friends

 The Above Code is Used to Scan and to Find Virus Upload the Attachment or files in the Server but its not working properly its executing well but its not generating any Details in Reports.txt What is the Problem i've Done i Dono with This Please Let Me Know ASAP

Regards.....,
R.V.Rajagopalan