對於以下代碼,我收到錯誤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