Win8 app判断网络连接状态
NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged; //网络连接发生变化时触发
private bool IsConnectedToInternet()//有无网络连接判断
{
bool connected = false;
ConnectionProfile Conpro = NetworkInformation.GetInternetConnectionProfile();
if (Conpro != null)
{
NetworkConnectivityLevel network = Conpro.GetNetworkConnectivityLevel();
connected = network == NetworkConnectivityLevel.InternetAccess;
}
return connected;
}