我正在 windows phone 8 上开发应用程序,并且想知道 - 是否可以检查检索到的设备 IP 地址是通过 Wifi 还是运营商?
Code used to find device IP address is -
public IPAddress IdentifyDeviceIp()
{
List<string> DeviceIPAddresses = new List<string>();
var DeviceHostnames = Windows.Networking.Connectivity.NetworkInformation.GetHostNames();
foreach (var DeviceHostName in DeviceHostnames)
{
if (DeviceHostName.IPInformation != null)
{
string DeviceIpAddress = DeviceHostName.DisplayName;
// Emulator: ignore IPV6 addresses
if (DeviceIpAddress.Contains(":"))
continue;
DeviceIPAddresses.Add(DeviceIpAddress);
}
}
if (DeviceIPAddresses.Count == 0)
{
MessageBox.Show("No IP address found!!");
return new IPAddress(0);
}
return IPAddress.Parse(DeviceIPAddresses[0]);
}