public static string GetLocalIp() { IPAddress localIp=null; try { IPAddress[] ipArray; ipArray=Dns.GetHostAddress(Dns.GetHostName()); localIp=ipArray.Frist(ip=>ip.AddressFamily==AddressFamily.InterNetwork); } catch(Exception ex) { } if(localIp==null) { localIp=IPAddress.Parse("127.0.0.1"); } return localIp.ToString(); }
时间: 2024-10-13 07:36:06