I want to ping any ip address and get the return value which shalt let me know whether it was successful or not. Something like that
if(ping.Equals(success)) { ... }
I want to ping any ip address and get the return value which shalt let me know whether it was successful or not. Something like that
if(ping.Equals(success)) { ... }
First result on google for "C# Ping". Examples near the bottom of the page.
But basically boils down to
Ping pingSender = new Ping ();
PingReply reply = pingSender.Send (ip, timeout);
if (reply.Status == IPStatus.Success)
//Success
else
//Failure
var sender = new Ping();
var result = sender.Send("127.0.0.1");
if (Result.Status == IPStatus.Success)
// OK
else
// it failed
Please note that you will need to add this using directive: System.Net.NetworkInformation