Wednesday, October 3, 2012

Retrieve Local IP using c#

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);

0 comments: