获取本机ip
public string GetIP()
{
IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
//txtlocalIP.Text = ips[0].ToString();
IPAddress ip = IPAddress.Parse("127.0.0.1");
foreach (IPAddress ipa in ips)
{
if (ipa.AddressFamily == AddressFamily.InterNetwork)
{
ip = ipa;
break;
}
}
string IPAdd = Convert.ToString(ip);
return IPAdd;
}