终于找到拉 using System.Net Dns.GetHostName();//获取本地计算机名 string str_ServerIP = Dns.Resolve( Dns.GetHostName() ).AddressList[0].ToString();//得到本地的IP地址
Sample code as follows: IPHostEntry hostInfo = Dns.GetHostByName( Dns.GetHostName() );// Get the IP address list that resolves to the host names contained in the // Alias property. IPAddress[] address = hostInfo.AddressList;foreach( IPAddress ip in address ) Debug.WriteLine( ip.ToString() );
using System.Net
Dns.GetHostName();//获取本地计算机名
string str_ServerIP = Dns.Resolve( Dns.GetHostName() ).AddressList[0].ToString();//得到本地的IP地址
IPHostEntry hostInfo = Dns.GetHostByName( Dns.GetHostName() );// Get the IP address list that resolves to the host names contained in the
// Alias property.
IPAddress[] address = hostInfo.AddressList;foreach( IPAddress ip in address )
Debug.WriteLine( ip.ToString() );