How to find if the Network is Available in WP7 using C#

How do one check if there is a open network connection in the Windows Phone 7 using c# ? .

You can achieve it through the static method GetIsNetworkAvailable() that is part of the NetworkInterface class .

You might require to include the namespace NetworkInformation incase you want to use this method.

using System.Net.NetworkInformation;

bool isAvailable = NetworkInterface.GetIsNetworkAvailable();

MessageBox.Show(isAvailable.ToString());

Note that when you use this method in the emulator , it will return always true , but in the device it should return the actual value .

The developers can also use the NetworkInterfaceType defined in the class “Microsoft.Phone.Net.NetworkInformation.NetworkInterface” property to detect the type of network connection .

MessageBox.Show(Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType.ToString());

The list of the Network Connection types are defined in the namespace “Microsoft.Phone.Net.NetworkInformation” and the
Microsoft.Phone.dll file .

Note that this will display Wireless80211 when i tried it in the emulator .

To know about the different connection types , you can find it on NetworkInterfaceType Enumeration

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

6 Comments

  1. John April 21, 2011 Reply
  2. How to find if the Network is Available in WP7 using C# August 1, 2011 Reply
  3. Yogesh1985 August 23, 2011 Reply
  4. medouederni December 23, 2011 Reply
  5. Saad Umair January 30, 2012 Reply

Leave a Reply


x

Interesting BlogPosts to read

How to get an Enumerator from range of elements from ArrayList in C# ?
The code snippet shown in this blog post demonstrates how you can get the enumeraor from a range of ...
How to check for the column name in an SqlDataReader Object in C# ?
When working in ADO.NET for data access , there are times when you want to check to see if a column ...
Download - Pokemon Go for for Windows 10 (Third Party app)
Pokemon Go is one of the popular AR games for android and iOS devices and now , the game is made ava...