本文介绍了如何检查连接的3G网络连接的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下方式:
public static bool IsNetworkConnected() { ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); IReadOnlyList<ConnectionProfile> connectionProfile = NetworkInformation.GetConnectionProfiles(); if (InternetConnectionProfile == null) return false; else return true; }
这当我在一个典型的方式连接到互联网的正常工作 - 通过LAN电缆或Wi-Fi。当我用我的3G USB调制解调器返回false( InternectConnectionProfile 为空)。这是为什么?我怎样才能解决这个问题?
It works fine when I'm connected to the internet in a typical way - via LAN cable or Wi-Fi. When I'm using my 3G USB modem it returns false (InternectConnectionProfile is null). Why is that? How can I fix it?
推荐答案您可以考虑在互联网上ping一台服务器。这不是100%的回答你的问题,但可能有助于从不同的角度来看。
You may consider pinging a server on the internet. This is not the 100% answer to your question but may be helpful from a different point of view.
using System.Net; using System.Net.NetworkInformation; using (Ping Packet = new Ping()) { if (Packet.Send(IPAddress.Parse(IP), 1000, new byte[] { 0 }).Status == IPStatus.Success)) { // ... } }更多推荐
如何检查连接的3G网络连接的状态?
发布评论