Sunday, November 28, 2010

Check If Network Connection Exists

We use the class System.Net.NetworkInformation.NetworkInterface to check, if the computer has a connection to a network.
The function needed for that is GetIsNetworkAvailable(). It checks, whether the computer is connected to a network by any adapter. However, it does not check, whether this network is working or having a connection to the internet.
The following code sample checks connectivity:

bool NetworkAvailable = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();

No comments:

Post a Comment