bool online = false; //是否在线 Ping ping = new Ping(); PingReply pingReply = ping.Send("192.168.132.191"); if (pingReply.Status == IPStatus.Success) { online = true; Console.WriteLine("当前在线,已ping通!"); } else { Console.WriteLine("不在线,ping不通!"); }
原文地址:http://blog.csdn.net/zht666/article/details/24592021