As mention in the subject,
i was trying to get the host IP address,
the code run perfectly , and i got an unexpected results...
Instead of IP address in IPv4 format , i got it in IPv6 format!
How shall i overcome this issue?
try
{
IPHostEntry ipentry = Dns.GetHostEntry(hostLabel.Text);
IPAddress[] addr = ipentry.AddressList;
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
{
| " + "\r\n";
}
}
Screenshot reference :
https://lh6.googleusercontent.com/-vn4v728bOQI/UCNu_rlz6II/AAAAAAAAANI/UYbtgxNqt-0/s616/Fullscreen+capture+982012+40215+PM.jpg[
^]