C# 设备终端网络是否能ping通

小猪肥

关注

阅读 121

2022-04-21

硬件系统集成中,经常需要查看设备网络是否通,此时就需要我们测试网络

public bool PingIp(string strIP)
        {
            bool bRet = false;
            try
            {
                Ping pingSend = new Ping();
                PingReply reply = pingSend.Send(strIP, 1000);
                if (reply.Status == IPStatus.Success)
                    bRet = true;
            }
            catch (Exception)
            {
                bRet = false;
            }
            return bRet;
        }

相关推荐

精彩评论(0)

0 0 举报