当我使用Windows Ping远程系统时,它说没有回复,但是当我用c#ping时,它表示成功.Windows正确,设备未连接.为什么我的代码能够在Windows不成功时成功ping?
这是我的代码:
Ping p1 = new Ping();
PingReply PR = p1.Send("192.168.2.18");
// check when the ping is not success
while (!PR.Status.ToString().Equals("Success"))
{
Console.WriteLine(PR.Status.ToString());
PR = p1.Send("192.168.2.18");
}
// check after the ping is n success
while (PR.Status.ToString().Equals("Success"))
{
Console.WriteLine(PR.Status.ToString());
PR = p1.Send("192.168.2.18");
}
Run Code Online (Sandbox Code Playgroud)