Possible Duplicate:
Get IPv4 addresses from Dns.GetHostEntry()
I try the following code to get my IP address, in XP, it returns the IP address V4 format, but when I do it in my system(windows 7), it return the ip address in v6 format.
How do to solve this?
Code
try
{
//iphostname = Dns.GetHostName(); // Resolving Host name
IPHostEntry ipentry = Dns.GetHostEntry(hostLabel.Text);
IPAddress[] addr = ipentry.AddressList;// Resolving IP Addresses
for (int i = 0; i < addr.Length; i++)
{
try
{
ipLabel.Text = Convert.ToString(addr[i]) + "\r\n";
}
catch
{
ipLabel.Text += "IP Address | " + "\r\n";
}
}
}
catch
{
//richTextBox1.Text += "Hostname | " + "\r\n";
}