Hier ein kleines Beispiel, das zeigt, wie man in einer Windows 8-App mit C# überprüfen kann, ob das System gerade Internetzugriff hat oder nicht:
Methode: CheckIfUserIsOnline
1 2 3 4 5 6 7 8 9 10 11 12 | private bool CheckIfUserIsOnline() { bool isOnline = false; ConnectionProfile profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile(); if (profile != null) { NetworkConnectivityLevel connectivityLevel = profile.GetNetworkConnectivityLevel(); if (connectivityLevel == NetworkConnectivityLevel.InternetAccess) isOnline = true; } return isOnline; } |