Check internet connection (availability) in Windows 8

mert picture mert · Nov 29, 2012 · Viewed 13.7k times · Source

How to check internet connection availability in Windows 8,C# development ? I looked at MSDN but page has been deleted.

Answer

Martin Suchan picture Martin Suchan · Nov 29, 2012

I use this snippet without problems:

public static bool IsInternet()
{
    ConnectionProfile connections = NetworkInformation.GetInternetConnectionProfile();
    bool internet = connections != null && connections.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess;
    return internet;
}