2013-05-13 93 views

回答

2

NetworkInformationConnectionCost和其他网络存在的API可以帮助您处理场景。它是否缺少您的特定应用程序所需的某些功能?

Kraig Brockschmidt有一个不错的implementation of a network connectivity test on his blog这可能是你在找什么。

+0

我用“如果(profile.GetConnectionCost()== NetworkCostType.Unrestricted){//使用高质量的数据}结束其他{//使用降低质量数据}使用WiFi/LAN或3G互联网时,它工作正常。 – 2013-05-16 18:11:14

8

您可以使用NetworkAdapter类找到网络类型。它有财产IanaInterfaceType。要检查所有的IANA界面,去here

var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile(); 
var interfaceType = profile.NetworkAdapter.IanaInterfaceType; 

// 71 is WiFi & 6 is Ethernet(LAN) 
if (interfaceType == 71 || interfaceType == 6) 
{ 
    //TODO: 
} 
// 243 & 244 is 3G/Mobile 
else if (interfaceType == 243 || interfaceType == 244) 
{ 
    //TODO: 
} 
相关问题