private string GetIPAddress()
{
IPAddress[] AddressList = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
string ipstr = "";
for(int i = 0; i < AddressList.Length; i++)
{
IPAddress ip = AddressList[i];
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
ipstr = ip.ToString();
break;
}
}
return ipstr;
}
C# 获取本机IP
最新推荐文章于 2023-12-20 21:20:48 发布