Monday, November 15, 2010

Finding Local IP Address in C#.NET

This snippet of code helps you find the local PC's IP Address from the Host Name. Be aware that it uses the IPv6 address if available.



 System.Net.IPHostEntry h =
            System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
            string IPAddress = h.AddressList.GetValue(0).ToString();
            string lm = System.Net.Dns.GetHostName().ToString();

No comments:

Post a Comment

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...