1.获取本机IP
/// <summary>
/// 获取本机所有IPV4地址列表e799bee5baa6e4b893e5b19e31333330343831
/// </summary>
/// <returns>本机所有IPV4地址列表,以分号分隔</returns>
public static string GetSelfIpv4List()
{
StringBuilder ips = new StringBuilder();
try
{
IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ipa in IpEntry.AddressList)
{
if (ipa.AddressFamily == AddressFamily.InterNetwork)
ips.AppendFormat("{0};", ipa.ToString());
}
}
catch (Exception ex)
{
}
return ips.ToString();
}
2.获取本机名称
///System.Net
Dns.GetHostName();