How to check for a network connection in .NET 2.0 (C# or VB)


To check for a network connection in .NET 2.0 use this:


System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()

To monitor a change in IP address or a change in network availability, use the events from the NetworkChange class:


System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged


System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged