对于以下代码,我收到错误System.Net.NetworkInformation.PingException
。如何处理C#中的ping异常?
Ping ping = new Ping();
PingReply stats = ping.Send(IPAddress.Parse("8.8.4.4"));
if (stats.Status == IPStatus.Success)
{
if(net)
textBox1.Text = "connected";
else
textBox1.Text="Not connected";
}
有人可以告诉这里有什么错吗?
注:第2行发生错误
是否有任何例外情况? – GrandMasterFlush 2012-01-27 10:06:17
看看'Exception'中的消息,它应该会给你更多的信息。此外,错误发生在哪一行? – 2012-01-27 10:07:00
@SamuelSlade第2行 – shiva 2012-01-27 12:36:55