This small function shows how to get the IPv4 address in Modern UI applications that are targeting the new Windows Store.
public string GetIPAddress()
{
IReadOnlyList<Windows.Networking.HostName> hostNames = Windows.Networking.Connectivity.NetworkInformation.GetHostNames();
foreach (Windows.Networking.HostName name in hostNames)
{
if (name.Type == Windows.Networking.HostNameType.Ipv4)
return name.DisplayName;
}
return string.Empty; ;
}
The usage cannot be simpler
string ip = GetIPAddress();