public bool pingNetworkStatus() { try { Ping a = new Ping(); PingReply re = a.Send("baidu.com"); return (re.Status == IPStatus.Success); } catch (Exception e) { Console.WriteLine(e.Message); } return false; } |
以往查看网络是否有连接是打开浏览器看看能不能打开百度~~没想到用代码也是这么搞的:-)