views:

391

answers:

2

I'm writing an application that will be used in a mobile environment where network connectivity will be up/down regularly. How do I check to see that a specific network is available?

+3  A: 

Try NetworkInterface.GetIsNetworkAvailable:

Indicates whether any network connection is available.

A network connection is considered to be available if any network interface is marked "up" and is not a loopback or tunnel interface.

Andrew Hare
+1  A: 

To see if any network is available you can use the VB.NET My namespace:

My.Computer.Network.IsAvailable

which I would guess is an abstraction of the NetworkInterface property in Andrew's answer. To see if you can use an available network to get to a specific server, you can use

My.Computer.Network.Ping(host name or IP address, or a System.Uri)
PhilPursglove