我想要创建一个应用程序来查找网络上的特定IP地址是否联机。我早就知道IP了。我对C#非常陌生,但我想知道是否有人能给我一个简单的解决方案。谢谢。
发布于 2016-06-25 18:19:00
Ping ping = new Ping ();
IPAddress address = IPAddress.Parse("000.000.000.000");
PingReply pong = pingSender.Send(address);pong对象包含信息,无论它是否成功。
if (pong.Status == IPStatus.Success)
{
// your machine at address is up and responding
}一个完整的程序,可以使用这个
using System;
using System.Net;
using System.Net.NetworkInformation;
public class Program
{
public static void Main()
{
Ping ping = new Ping();
//change the following ip variable into the ip adress you are looking for
string ip = " ";
IPAddress address = IPAddress.Parse(ip);
PingReply pong = ping.Send(address);
if (pong.Status == IPStatus.Success)
{
Console.WriteLine(ip + " is up and running.");
}
}
}https://stackoverflow.com/questions/38031446
复制相似问题