2013-05-13 74 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: 
} 
相關問題