摘要: 通过适配器判断网络连接类型及状态 判断网络的连接状态/连接类型,可以直接查看网络适配器列表的状态 适配器列表: 1 public static NetworkInterface[] GetAllAdapters() 2 { 3 //获取本地计算机上网络接口的对象 4 NetworkInterface 阅读全文
posted @ 2020-05-27 14:43 唐宋元明清2188 阅读(621) 评论(0) 推荐(1) 编辑
摘要: 网络连接判断,使用WebClient测试获取: 1 public static bool IsWebClientConnected() 2 { 3 try 4 { 5 using (var client = new WebClient()) 6 using (var stream = client. 阅读全文
posted @ 2020-05-27 14:42 唐宋元明清2188 阅读(382) 评论(0) 推荐(1) 编辑
摘要: 网络连接判断,使用IPHost测试获取: 1 public static bool IsIPHostConnected() 2 { 3 try 4 { 5 System.Net.IPHostEntry i = System.Net.Dns.GetHostEntry("www.google.com") 阅读全文
posted @ 2020-05-27 14:41 唐宋元明清2188 阅读(397) 评论(2) 推荐(1) 编辑
摘要: 网络连接判断,使用ping测试获取: 1 private static async Task<bool> IsPingSuccess() 2 { 3 try 4 { 5 using (Ping myPing = new Ping()) 6 { 7 var result = await myPing. 阅读全文
posted @ 2020-05-27 14:40 唐宋元明清2188 阅读(379) 评论(0) 推荐(1) 编辑
摘要: IsNetworkAlive需要服务System Event Notification的支持(系统默认自动启动该服务),且需要安装最新的SDK(如.NET) 浏览:MSDN对IsNetworkAlive的详细描述 由API中翻译:该功能可在Windows XP、2000(或Windows NT 4. 阅读全文
posted @ 2020-05-27 14:39 唐宋元明清2188 阅读(1305) 评论(0) 推荐(1) 编辑