我想检查我的手机是否可以连接到互联网。我已经看到了几个问题。其中之一是Question。它说要使用NetworkInterface.GetIsNetworkAvailable()
它,我试过了。我已经断开了我的电脑与互联网的连接,还关闭了DataConnection
模拟器,但这NetworkInterface.GetIsNetworkAvailable()
总是返回 true。但同时我也检查了NetworkInterfaceType.None
它,有趣的是它即将为空。谁能解释我在哪里缺少信息?
尝试:-
public static void CheckNetworkAvailability()
{
// this is coming true even when i disconnected my pc from internet.
// i also make the dataconnection off of the emulator
var fg = NetworkInterface.GetIsNetworkAvailable();
var ni = NetworkInterface.NetworkInterfaceType;
// this part is coming none
if (ni == NetworkInterfaceType.None)
IsConnected = false;
}
任何帮助表示赞赏:)