Hi,
I want to detect IP address from user's computer after button click. So, it will show out the IP address on a textbox. How should i write my code?
Thx a lots!
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
abdullah majidPosted Feb 13, 2011, 1:01 PM
^_^
Posted Nov 30, 2010, 4:40 PM
Use System.Net namespace.
private void button1_Click(object sender, RoutedEventArgs e)
{
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
IPAddress[] address = hostEntry.AddressList;
textBox1.Text = address.GetValue(1).ToString();
//MessageBox.Show(address.GetValue(1).ToString());
}
Hope this helps you.