Saturday, September 19, 2009

Getting Local Network Information

on C# when you are performing any application realated with network and in this case if you want information regarding the local network adaptors or local machines network configuration, then you can use the static method System.Net.NetworkInformation.GetAllNetworkInterfaces. it will returns objects of type NetworkInterface.
The properties of the NetworkInterface object will unravel a rich set of information regarding network configuration and network statistics.

here is Sample Code:



using System.Net.NetworkInformation;

if(NetworkInterface.GetIsNetworkAvailable()){

NetworkInterface[] nInterface = NetworkInterface.GetAllNetworkInterfaces();

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


hope it will helps you.

No comments:

Post a Comment