1
(1) 获取本地IP:
string HostName = Dns.GetHostName(); //获取主机名 IPHostEntry MyEntry = Dns.GetHostByName(Dns.GetHostName()); //获取有关ip信息IPAddress MyAddress = new IPAddress(MyEntry.AddressList[0].Address);//获取ip