Ping p =new Ping(); PingReply pr; pr = p.Send("119.75.218.45");//百度的IP if(pr.Status != IPStatus.Success)//如果连接不成功 { Console.WriteLine("未联网"); } else { Console.WriteLine("已联网"); } Console.Read();