Retrieve Local IP using c#, Get Local IP using c#
//add System.Net namespace
//using System.Net;
string localIP = "";
foreach (IPAddress ip in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
{
if (ip.AddressFamily.ToString() == "InterNetwork")
{
localIP = ip.ToString();
}
}
MessageBox.Show(localIP);
//add System.Net namespace
//using System.Net;
string localIP = "";
foreach (IPAddress ip in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
{
if (ip.AddressFamily.ToString() == "InterNetwork")
{
localIP = ip.ToString();
}
}
MessageBox.Show(localIP);
0 comments:
Post a Comment