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?
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With