获取IP并写入hosts文件
1String ss = "要获取IP的域名";
2IPHostEntry hostInfo = Dns.GetHostByName(ss);
3IPAddress ip = hostInfo.AddressList[0];
4textIP.Text = ip.ToString();
5StreamWriter sw = new StreamWriter ("C:\\Windows\\System32\\Drivers\\etc\\hosts");
6sw.WriteLine(ip.ToString() + "\0映射的地址");
7sw.Close();
2IPHostEntry hostInfo = Dns.GetHostByName(ss);
3IPAddress ip = hostInfo.AddressList[0];
4textIP.Text = ip.ToString();
5StreamWriter sw = new StreamWriter ("C:\\Windows\\System32\\Drivers\\etc\\hosts");
6sw.WriteLine(ip.ToString() + "\0映射的地址");
7sw.Close();