0
Answer

Get IP Address

rottenvx

rottenvx

19y
1.9k
1
I am using the following code to get the localhost's internal (aka LAN) IP address (i.e. 192.168.1.1) public string GetIPAddress() { IPAddress addr = IPAddress.Any; IPHostEntry host = Dns.GetHostByAddress(addr); if (host.AddressList.Length == 0) { return "Unavailable"; } return host.AddressList[0].ToString(); } It has been working perfectly under Win2k but since I upgraded my Win2k box to Windows XP Professional this function return just "0.0.0.0" to me, even if the same project code has been preserved and same IP addressing is used by the same box. Can anyone please help me understand this anomaly and alternatively help me code a function that can return both internal and external IP addresses ? Thanks in advance.