C# - How to detect all IP addresses from a LAN?

Posted by SAMIR BHOGAYTA on Samir ASP.NET with C# Technology See other posts from Samir ASP.NET with C# Technology or by SAMIR BHOGAYTA
Published on 2011-06-18T23:23:00.001-07:00 Indexed on 2011/06/20 16:37 UTC
Read the original article Hit count: 299

string strHostName = string.Empty;

cmbIPAddress.Items.Clear();

// Getting Ip address of local machine...
// First get the host name of local machine.

strHostName = Dns.GetHostName();

// Then using host name, get the IP address list..

IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
IPAddress[] iparrAddr = ipEntry.AddressList;

if (iparrAddr.Length > 0)
{
for (int intLoop = 0; intLoop < iparrAddr.Length; intLoop++)
cmbIPAddress.Items.Add(iparrAddr[intLoop].ToString());
}


© Samir ASP.NET with C# Technology or respective owner

Related posts about C# - How to detect all IP addresses from a LAN?