我有一个 ajax 上传器,允许用户将图片上传到程序,然后再显示给用户。我想在允许该文件保留在服务器中之前检查该文件是否有病毒。以下是将文件发送到病毒扫描程序的代码。我希望能够查看扫描结果是否产生病毒,如果确实有病毒,则将其从服务器中删除。
try
{
Process myProcess = new Process();
myProcess.StartInfo.FileName = @"C:\Program Files\AVG\AVG8\avgscanx.exe";
//myProcess.StartInfo.FileName=@"C:\Program Files\ClamWin\bin\clamscan.exe";
string myprocarg = @"""C:\Documents and Settings\Administrator.USER20501\My Documents\Luke's Projects\DADS\212\Images\FinalLogo" + file.ClientFileName + @"""";
myProcess.StartInfo.Arguments = myprocarg;
myProcess.OutputDataReceived += new DataReceivedEventHandler(myProcess_OutputDataReceived);
myProcess.ErrorDataReceived += new DataReceivedEventHandler(myProcess_ErrorDataReceived);
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
myProcess.BeginOutputReadLine();
myProcess.WaitForExit();
}
catch (Exception)
{
}
void myProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
// this value will always be null.......
string s = e.Data.ToString();
}
void myProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
string s = e.Data.ToString();
}