Search This Blog

Tuesday, September 22, 2009

Quick/Simple Ping in C#

private string PingServers(string host)
{
  try
  {
    System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
    System.Net.NetworkInformation.PingReply pingReply = ping.Send(host);
    return "Status: " + pingReply.Status.ToString();
  }
  catch (System.Net.NetworkInformation.PingException e)
  {
    return e.Message;
  }
}

No comments: