Checking network status in C#

If you just want to check if the network is up then use:

bool networkUp
    = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();

To check a specific interface’s status (or other info) use:

NetworkInterface[] networkCards
    = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();

To check the status of a remote computer then you’ll have to connect to that computer (see other answers)

Leave a Comment