Click here to Skip to main content
16,012,116 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
my code is here:
C#
string myHost = System.Net.Dns.GetHostName();
   System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(myHost);
   foreach (System.Net.IPAddress myIP in myIPs.AddressList)
    {
          TextBox1.Text = myIP.ToString();
   }
Posted
Updated 7-Feb-12 0:29am
v2

1 google search leads to: this[^]
better link BitBotBop hint![^]

Google search here[^]
 
Share this answer
 
v2
use
C#
TextBox1.Text = myIP[0].ToString();

as
C#
try
{
    string sHostName = textBox1.Text;
    System.Net.IPHostEntry ipE = System.Net.Dns.GetHostEntry(sHostName);
    System.Net.IPAddress[] IpA = ipE.AddressList;
    textBox2.Text = IpA[0].ToString();
}
catch(Exception ex)
{
    textBox2.Text = ex.ToString();
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900