private static bool Ping(string machineName)
{
try
{
Ping pingSender = new Ping();
PingOptions options = new PingOptions();
options.DontFragment = true;
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
PingReply reply = pingSender.Send(machineName, timeout, buffer, options);
if (reply.Status != IPStatus.Success)
{
return false;
}
}
catch (Exception)
{
return false;
}
return true;
}
沒有留言:
張貼留言