using System.Net.NetworkInformation;public bool IsConnected(){ Ping ping = new Ping (); PingReply reply = ping.Send("www.baidu.com"); return (reply.Status == IPStatus.Success);}