Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
你如何检查用户是否连接到互联网?我有一个使用服务的程序,我想先检查一下
谢谢
如http://www.diaryofaninja.com/blog/2010/12/09/checking-for-network-connectivity-in-windows-phone-7-sdk所示:
if (NetworkInterface.GetIsNetworkAvailable()) { }
应该是正确的方法。
电话 api 没有互联网访问状态。尽管有各种状态,您仍需要实际拨打电话以测试它是否可用。请参阅使用 .NET 检查 Internet 连接的最佳方法是什么?