public string GetPublicIP() { String direction = ""; WebRequest request = WebRequest.Create("http://checkip.dyndns.org/"); using (WebResponse response = request.GetResponse()) using (StreamReader stream = new StreamReader(response.GetResponseStream())) { direction = stream.ReadToEnd(); } //Search for the ip in the html int first = direction.IndexOf("Address: ") + 9; int last = direction.LastIndexOf("</body>"); direction = direction.Substring(first, last - first); return direction; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)