我正在开发一个基本构建到 Windows 商店和 Xbox 的 uwp 应用程序。
我的代码就像
var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
var networkType=null;
var interfaceType = profile.NetworkAdapter.IanaInterfaceType;
// 71 is WiFi & 6 is Ethernet
if (interfaceType == 71)
{
networkType="wifi";
}
else if (interfaceType == 6)
{
networkType="ethernet";
}
当我连接到 wifi 并在 xbox 中运行此代码时,我得到的连接类型为“以太网”,但是当我在本地机器上运行相同的代码时,我得到的值是 wifi。
任何帮助表示赞赏:)