C#获取本机IP搜集整理7种方法:http://blog.csdn.net/frombegintoend/article/details/7713097
使用IPHostEntry获取本机局域网地址
string hostName = Dns.GetHostName();
IPHostEntry localHost = Dns.GetHostEntry(hostName);
for (int i=; i < localHost.AddressList.Length ; ++i)
{
if (localHost.AddressList[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
Console.WriteLine(localHost.AddressList[i].ToString());
}
}