Ping a machine using c#.net

Name space: using System.Net.NetworkInformation;
try
{
Ping oping = new Ping();
PingReply oReply = oping.Send(machineipaddress);
if (oReply.Status.ToString().ToLower() != "success")
{
MessageBox.Show("Unable to ping the machine " + machineipaddress + "\n\n\t" + oReply.Status);
Environment.Exit(0);
}
}
catch (PingException ex)
{
MessageBox.Show("Error while pinging the machine " + machineipaddress + "\n\n" + ex.Message);
Environment.Exit(0);
}

1 comments:

Unknown July 29, 2008 at 12:08 AM  

Nalla irruku but include the namespace while posting codes

Listen to nirmaln - sakara - playlist audio songs at MusicMazaa.com