日期:2014-05-17 浏览次数:20586 次
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "ping.exe";
process.StartInfo.Arguments = "www.qq.com";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.Start();
System.IO.StreamReader reader = process.StandardOutput;
string data = reader.ReadLine();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
while (data != null)
{
sb.Append(data);
data = reader.ReadLine();
}
if(sb.ToString().IndexOf("Ping 请求找不到主机")>=0)
'ping不通
else
'ping通了