What is the syntax for getting the computer's own (if possible, external) IP address?
IPHostEntry host; string localIP = "?";
host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) {
if (ip.AddressFamily.ToString() == "InterNetwork")
{
localIP = ip.ToString();
} } return localIP;
IPHostEntry host; string localIP = "?";
host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) {
if (ip.AddressFamily.ToString() == "InterNetwork")
{
localIP = ip.ToString();
} } return localIP;
No comments:
Post a Comment