/// <summary>
/// 判断是否连接网络
/// </summary>
/// <returns></returns>
public static bool IsInternet()
{
var status = false;
//判断是否联网
try
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply res = ping.Send("www.baidu.com");
if (res.Status == System.Net.NetworkInformation.IPStatus.Success)
{
//连接上Internet
status = true;
}
}
catch
{
status = false;
}
return status;
}