c# - Identification of active network card and get Default Gateway -


this question has answer here:

how identification of active network card , default gateway?

http://s4.picofile.com/file/7871762682/default_gateway.png

the following code gives first default gateway:

 networkinterface card = networkinterface.getallnetworkinterfaces().firstordefault();  if (card == null)     return null;  gatewayipaddressinformation address = card.getipproperties().gatewayaddresses.firstordefault();  if (address == null)      return null;   return address.address; 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -