I am trying to make an application but for it to work it needs your IP in a text box... So I am trying to use this code to make it work, but it is not working:
private void Form1_Load(object sender, EventArgs e)
{
myIPAddress.Text = getMyIPAddress();
}
private void getMyIPAddress()
{
string Address = "";
WebRequest request = WebRequest.Create("http://checkip.dyndns.org/");
using (WebResponse response = request.GetResponse())
using (StreamReader stream = new StreamReader(response.GetResponseStream()))
{
Address = stream.ReadToEnd();
}
int first = Address.IndexOf("Address: ") + 9;
int last = Address.IndexOf("</body>");
Address = Address.Substring(first, last - first);
return Address;
}