积极答复者
C#metro程序如何判断网络是否通?即是否能上网?谢谢!!!最好耗时少。。。

问题
答案
-
您好!
您可以通过 ConnectionProfile.GetNetworkConnectivityLevel 方法,获取可访问的网络状态。
样例代码如下。
ConnectionProfile profile = NetworkInformation.GetInternetConnectionProfile(); NetworkConnectivityLevel connLevel = profile.GetNetworkConnectivityLevel(); switch (connLevel) { case NetworkConnectivityLevel.None: { // no internet access break; } case NetworkConnectivityLevel.InternetAccess: { // internet access is available break; } // other status default: { // other break; } }
Best wishes,
Robin [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 sn0ww0lfme 2012年5月17日 8:49
-
全部回复
-
您好!
您可以通过 ConnectionProfile.GetNetworkConnectivityLevel 方法,获取可访问的网络状态。
样例代码如下。
ConnectionProfile profile = NetworkInformation.GetInternetConnectionProfile(); NetworkConnectivityLevel connLevel = profile.GetNetworkConnectivityLevel(); switch (connLevel) { case NetworkConnectivityLevel.None: { // no internet access break; } case NetworkConnectivityLevel.InternetAccess: { // internet access is available break; } // other status default: { // other break; } }
Best wishes,
Robin [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 sn0ww0lfme 2012年5月17日 8:49
-