WPF 获取IP地址

 



            List<string> ipList = new List<string>();

            foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)

            {

                if (_IPAddress.AddressFamily.ToString() == "InterNetwork")

                {

                    ipList.Add(_IPAddress.ToString());

                }

            }

            

 

你可能感兴趣的:(IP地址)