【发布时间】:2012-11-19 15:54:35
【问题描述】:
我有这个方法:
public static void testConnection()
{
if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
{
System.Windows.MessageBox.Show("This computer is connected to the internet");
}
else
{
System.Windows.MessageBox.Show("This computer is not connected to the internet");
}
}
我想它会告诉我连接是否可用,但即使我确定没有连接,它也总是返回 true(并打印第一条消息)。我做错了什么?
P.S.:我还在学习 C#。
【问题讨论】:
-
@TimSchmelter 我不明白,这是一个空白页。哦哦;)
-
NetworkInterface.GetIsNetworkAvailable()不检查互联网连接。它只检查是否有任何网络连接可用。看到这个检查互联网连接。 stackoverflow.com/questions/5405895/…
标签: c# windows networking