Wednesday, October 18, 2006

Getting Local Network Information


So you want information regarding the local network adaptors and the local machines network configuration, use the static method System.Net.NetworkInformation.GetAllNetworkInterfaces. This returns objects of type NetworkInterface. The properties of the NetworkInterface object will unravel a rich set of information regarding network configuration and network statistics.

Sample Code:

using System.Net.NetworkInformation;


--if(NetworkInterface.GetIsNetworkAvailable()){

----NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();

----foreach(NetworkInterface ni in interfaces){
------string NetworkName = ni.Name;
----}

--}

No comments: