Public Function GetIPAddress() As String Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName) Return h.AddressList.GetValue(0).ToString End Function
public string GetIPAddress() { string myHost = System.Net.Dns.GetHostName(); string myIP = null; for (int i = 0; i <= System.Net.Dns.GetHostEntry(myHost).AddressList.Length - 1; i++) { if (System.Net.Dns.GetHostEntry(myHost).AddressList[i].IsIPv6LinkLocal == false) { myIP = System.Net.Dns.GetHostEntry(myHost).AddressList[i].ToString(); } } return myIP; }
Last Updated on November 13, 2015