using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;
using System.Diagnostics;
using Webb.WAVE.Controls.Upload;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using System.Xml.XPath;
using System.Runtime.InteropServices;namespace virus
{
/// <summary>
/// WebForm1 的摘要描述。
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label1; public class WNetConnectionHelper
{
[DllImport("mpr.dll", EntryPoint = "WNetAddConnection2")] private static extern uint WNetAddConnection2(NetResource lpNetResource, string lpPassword, string lpUsername, uint dwFlags);
[DllImport("Mpr.dll", EntryPoint = "WNetCancelConnection2")] private static extern uint WNetCancelConnection2(string lpName, uint dwFlags, bool fForce);
[StructLayout(LayoutKind.Sequential)] public class NetResource { public int dwScope; public int dwType; public int dwDisplayType; public int dwUsage; public string lpLocalName; public string lpRemoteName; public string lpComment; public string lpProvider; }
public static uint WNetAddConnection(NetResource netResource,string username,string password) { uint result = WNetAddConnection2(netResource, password, username, 0); return result; }
public static uint WNetAddConnection(string username, string password, string remoteName, string localName) { NetResource netResource = new NetResource(); netResource.dwScope = 2; //RESOURCE_GLOBALNET netResource.dwType = 1; //RESOURCETYPE_ANY netResource.dwDisplayType = 3; //RESOURCEDISPLAYTYPE_GENERIC netResource.dwUsage = 1; //RESOURCEUSAGE_CONNECTABLE netResource.lpLocalName = localName; netResource.lpRemoteName = remoteName.TrimEnd('\\'); //netResource.lpRemoteName = lpComment; //netResource.lpProvider = null; uint result = WNetAddConnection2(netResource, password, username, 0); return result; }
public static uint WNetCancelConnection(string name,uint flags,bool force) { uint nret = WNetCancelConnection2(name, flags, force); return nret; }
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在這裡放置使用者程式碼以初始化網頁
WebbUpload m_upload = new WebbUpload();
m_upload.RegisterProgressBar(Button1);
} #region Web Form 設計工具產生的程式碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 此為 ASP.NET Web Form 設計工具所需的呼叫。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string m_content= HttpContext.Current.Request["file1"];
string[] contentArray = m_content.Split(';');
string m_temp = contentArray[0];
string m_contenttype = m_temp.Substring(m_temp.IndexOf(":")+1).Trim();
m_temp = contentArray[1];
string m_clientName = m_temp.Substring(m_temp.IndexOf("\"")+1,m_temp.LastIndexOf("\"")-m_temp.IndexOf("\"")-1).Trim();
string[] contentArray1 = m_clientName.Split('\\');
m_temp = contentArray[2];
string m_filename = m_temp.Substring(m_temp.IndexOf("\"")+1,m_temp.LastIndexOf("\"")-m_temp.IndexOf("\"")-1).Trim();
string sFileName=contentArray1[contentArray1.Length-1].ToString();
UploadFile m_file = new UploadFile("file1");
m_file.SaveAs("d:\\scanvirus\\"+contentArray1[contentArray1.Length-1].ToString());
virus();
} private void virus()
{
string m_content= HttpContext.Current.Request["file1"];
string[] contentArray = m_content.Split(';');
string m_temp = contentArray[0];
string m_contenttype = m_temp.Substring(m_temp.IndexOf(":")+1).Trim();
m_temp = contentArray[1];
string m_clientName = m_temp.Substring(m_temp.IndexOf("\"")+1,m_temp.LastIndexOf("\"")-m_temp.IndexOf("\"")-1).Trim();
string[] contentArray1 = m_clientName.Split('\\');
m_temp = contentArray[2];
string m_filename = m_temp.Substring(m_temp.IndexOf("\"")+1,m_temp.LastIndexOf("\"")-m_temp.IndexOf("\"")-1).Trim();
string sFileName=contentArray1[contentArray1.Length-1].ToString();
string sfile=@"d:\scanvirus\"+sFileName;
string time=DateTime.Now.ToString("yyyyMMddhhmmss");
string file= sFileName+time;
uint nodr = WNetConnectionHelper.WNetAddConnection("192.168.38.137\\scan","3324",@"\\192.168.38.137\c$","n:");
ProcessStartInfo nodpsi=new ProcessStartInfo();
nodpsi.FileName=@"N:\Program Files\ESET\ESET NOD32 Antivirus\ecls.exe";
nodpsi.Arguments =@" "+sfile+" ";
nodpsi.UseShellExecute = false;
nodpsi.RedirectStandardOutput = true;
nodpsi.RedirectStandardInput = true;
nodpsi.RedirectStandardError = true;
// psi.WorkingDirectory = "d:"; //Start the Process
System.Diagnostics.Process nodproc = System.Diagnostics.Process.Start(nodpsi); //Attach the output for reading
System.IO.StreamReader nodsOut = nodproc.StandardOutput;
//Attach the in for writing
System.IO.StreamWriter nodsIn = nodproc.StandardInput; //Exit CMD.EXE
// string stEchoFmt = "#{0}run successfully.Exiting"; nodsIn.WriteLine("EXIT");
//Close the process
nodproc.Close();
//Read the sOut to a string
string nodresults = nodsOut.ReadToEnd();
XmlDocument nodxmldoc = new XmlDocument();
//加入一個根項目
XmlElement nodroot = nodxmldoc.CreateElement("bookstore");
nodxmldoc.AppendChild(nodroot);
XmlElement nodxe1 = nodxmldoc.CreateElement("book");
nodxe1.SetAttribute("genre", "fantasy");
nodxe1.SetAttribute("ISBN", "2-3631-4");
XmlElement nodxesub1 = nodxmldoc.CreateElement("PN");
nodxesub1.InnerText = nodresults;
nodxe1.AppendChild(nodxesub1);
nodroot.AppendChild(nodxe1);
nodroot.AppendChild(nodxesub1);
nodxmldoc.Save(Server.MapPath(".")+"\\Log\\"+file+".xml");
//Close the io Streams;
nodsIn.Close();
nodsOut.Close();
//Write out the results
string fmtStdOut = " <font face = courier size=0>{0} </font>";
this.Response.Write(String.Format(fmtStdOut,nodresults.Replace(System.Environment.NewLine," <br/>")));
}
}
}
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;
using System.Diagnostics;
using Webb.WAVE.Controls.Upload;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using System.Xml.XPath;
using System.Runtime.InteropServices;namespace virus
{
/// <summary>
/// WebForm1 的摘要描述。
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label1; public class WNetConnectionHelper
{
[DllImport("mpr.dll", EntryPoint = "WNetAddConnection2")] private static extern uint WNetAddConnection2(NetResource lpNetResource, string lpPassword, string lpUsername, uint dwFlags);
[DllImport("Mpr.dll", EntryPoint = "WNetCancelConnection2")] private static extern uint WNetCancelConnection2(string lpName, uint dwFlags, bool fForce);
[StructLayout(LayoutKind.Sequential)] public class NetResource { public int dwScope; public int dwType; public int dwDisplayType; public int dwUsage; public string lpLocalName; public string lpRemoteName; public string lpComment; public string lpProvider; }
public static uint WNetAddConnection(NetResource netResource,string username,string password) { uint result = WNetAddConnection2(netResource, password, username, 0); return result; }
public static uint WNetAddConnection(string username, string password, string remoteName, string localName) { NetResource netResource = new NetResource(); netResource.dwScope = 2; //RESOURCE_GLOBALNET netResource.dwType = 1; //RESOURCETYPE_ANY netResource.dwDisplayType = 3; //RESOURCEDISPLAYTYPE_GENERIC netResource.dwUsage = 1; //RESOURCEUSAGE_CONNECTABLE netResource.lpLocalName = localName; netResource.lpRemoteName = remoteName.TrimEnd('\\'); //netResource.lpRemoteName = lpComment; //netResource.lpProvider = null; uint result = WNetAddConnection2(netResource, password, username, 0); return result; }
public static uint WNetCancelConnection(string name,uint flags,bool force) { uint nret = WNetCancelConnection2(name, flags, force); return nret; }
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在這裡放置使用者程式碼以初始化網頁
WebbUpload m_upload = new WebbUpload();
m_upload.RegisterProgressBar(Button1);
} #region Web Form 設計工具產生的程式碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 此為 ASP.NET Web Form 設計工具所需的呼叫。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string m_content= HttpContext.Current.Request["file1"];
string[] contentArray = m_content.Split(';');
string m_temp = contentArray[0];
string m_contenttype = m_temp.Substring(m_temp.IndexOf(":")+1).Trim();
m_temp = contentArray[1];
string m_clientName = m_temp.Substring(m_temp.IndexOf("\"")+1,m_temp.LastIndexOf("\"")-m_temp.IndexOf("\"")-1).Trim();
string[] contentArray1 = m_clientName.Split('\\');
m_temp = contentArray[2];
string m_filename = m_temp.Substring(m_temp.IndexOf("\"")+1,m_temp.LastIndexOf("\"")-m_temp.IndexOf("\"")-1).Trim();
string sFileName=contentArray1[contentArray1.Length-1].ToString();
UploadFile m_file = new UploadFile("file1");
m_file.SaveAs("d:\\scanvirus\\"+contentArray1[contentArray1.Length-1].ToString());
virus();
} private void virus()
{
string m_content= HttpContext.Current.Request["file1"];
string[] contentArray = m_content.Split(';');
string m_temp = contentArray[0];
string m_contenttype = m_temp.Substring(m_temp.IndexOf(":")+1).Trim();
m_temp = contentArray[1];
string m_clientName = m_temp.Substring(m_temp.IndexOf("\"")+1,m_temp.LastIndexOf("\"")-m_temp.IndexOf("\"")-1).Trim();
string[] contentArray1 = m_clientName.Split('\\');
m_temp = contentArray[2];
string m_filename = m_temp.Substring(m_temp.IndexOf("\"")+1,m_temp.LastIndexOf("\"")-m_temp.IndexOf("\"")-1).Trim();
string sFileName=contentArray1[contentArray1.Length-1].ToString();
string sfile=@"d:\scanvirus\"+sFileName;
string time=DateTime.Now.ToString("yyyyMMddhhmmss");
string file= sFileName+time;
uint nodr = WNetConnectionHelper.WNetAddConnection("192.168.38.137\\scan","3324",@"\\192.168.38.137\c$","n:");
ProcessStartInfo nodpsi=new ProcessStartInfo();
nodpsi.FileName=@"N:\Program Files\ESET\ESET NOD32 Antivirus\ecls.exe";
nodpsi.Arguments =@" "+sfile+" ";
nodpsi.UseShellExecute = false;
nodpsi.RedirectStandardOutput = true;
nodpsi.RedirectStandardInput = true;
nodpsi.RedirectStandardError = true;
// psi.WorkingDirectory = "d:"; //Start the Process
System.Diagnostics.Process nodproc = System.Diagnostics.Process.Start(nodpsi); //Attach the output for reading
System.IO.StreamReader nodsOut = nodproc.StandardOutput;
//Attach the in for writing
System.IO.StreamWriter nodsIn = nodproc.StandardInput; //Exit CMD.EXE
// string stEchoFmt = "#{0}run successfully.Exiting"; nodsIn.WriteLine("EXIT");
//Close the process
nodproc.Close();
//Read the sOut to a string
string nodresults = nodsOut.ReadToEnd();
XmlDocument nodxmldoc = new XmlDocument();
//加入一個根項目
XmlElement nodroot = nodxmldoc.CreateElement("bookstore");
nodxmldoc.AppendChild(nodroot);
XmlElement nodxe1 = nodxmldoc.CreateElement("book");
nodxe1.SetAttribute("genre", "fantasy");
nodxe1.SetAttribute("ISBN", "2-3631-4");
XmlElement nodxesub1 = nodxmldoc.CreateElement("PN");
nodxesub1.InnerText = nodresults;
nodxe1.AppendChild(nodxesub1);
nodroot.AppendChild(nodxe1);
nodroot.AppendChild(nodxesub1);
nodxmldoc.Save(Server.MapPath(".")+"\\Log\\"+file+".xml");
//Close the io Streams;
nodsIn.Close();
nodsOut.Close();
//Write out the results
string fmtStdOut = " <font face = courier size=0>{0} </font>";
this.Response.Write(String.Format(fmtStdOut,nodresults.Replace(System.Environment.NewLine," <br/>")));
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货