/// <summary>
/// 獲取本機ip
/// </summary>
/// <returns></returns>
public static string getLocalIP()
{
string strHostName = Dns.GetHostName(); //得到本機的主機名
IPHostEntry ipEntry = Dns.GetHostByName(strHostName); //取得本機IP
string strAddr = ipEntry.AddressList[0].ToString();
return (strAddr);
}
本文出自 “狼之魂” 博客