Keep in touch

you can keep in touch with my all blogs and sites by install this Toolbar...
http://rworldtoolbar.ourtoolbar.com/

Friday, September 12, 2008

How to ping a computer using windows application

// Pass host name or IP Address.
public void PingHost(string host)
{
try
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply pingReply = ping.Send(host);

MessageBox.Show("Status: " + pingReply.Status.ToString());
}
catch (System.Net.NetworkInformation.PingException e)
{
MessageBox.Show(e.Message);
}
}

private void button1_Click(object sender, EventArgs e)
{
PingHost(textBox1.Text.Trim());
}

No comments: