1

I need to check if a network interface is currently connected to a network, disconnected, or if it's been disabled. Consider the gross code below:

NetworkInterface[] nics = NetworkInterface;
            while(true)
            {
                Console.WriteLine(nics[4].OperationalStatus);
            }

What this never ending loop does is check the operational status of a network interface card. When the loop starts, the status is Up, but when I disconnect from the network or manually disable that NIC, operational status will remain Up.

How can I check if a specific NIC is connected, disconnected, or disabled? I would like to accomplish this without having to ping an external source.

Thanks!

GreenSaber
  • 1,118
  • 2
  • 26
  • 53
  • You might want to take a look here: https://stackoverflow.com/questions/2200798/how-can-i-see-if-a-network-connection-changes-state – danish May 09 '18 at 12:17

0 Answers0