Thursday, June 10, 2010

How to check if internet connection is available or not in WPF

In one of the applications I wanted to know if I am connected to internet or not... I looked around and found this solution.


I guess it has some problems when VPN connections are setup on the machine. But otherwise it works just fine.


Steps:
1] Refer System.net dll in your WPF project
2] Where you want to check for the connection, use this code


 NetworkInterface.GetIsNetworkAvailable();

..

No comments:

Post a Comment