Ping an IP address using C#

The following example explains how to ping an IP address by using the class PING. This class determine whether a remote computer is accessible via network. It provides similar functionality as PING.EXE command line tool. So let's create this simple application.

First, remember to add "System.Net.NetworkInformation" directive at the top:

using System.Net.NetworkInformation;

Then, this code to ping the IP address:

private void PingButton_Click(object sender, EventArgs e)
{
    Ping ping = new Ping();
    PingReply reply = ping.Send(textBox1.Text,1000);
            
    MessageBox.Show(reply.Status.ToString());        
}

To understand more, check this video:




Ping an IP address using C# Ping an IP address using C# Reviewed by Bloggeur DZ on 11:55 Rating: 5

2 commentaires:

Fourni par Blogger.