find all ip address in a network

前端 未结 5 2030
逝去的感伤
逝去的感伤 2020-11-30 10:24

I am trying to do this C#. I need to find all ip address that are active in my network and show them in a list. I can ping all available (1...255) ip address in a network. B

5条回答
  •  粉色の甜心
    2020-11-30 11:05

        public static void NetPing()
        {            
            Ping pingSender = new Ping();
            foreach (string adr in stringAddressList)
            {
               IPAddress address = IPAddress.Parse(adr);
               PingReply reply = pingSender.Send (address);
    
               if (reply.Status == IPStatus.Success)
               {
                    //Computer is active
               }
               else
               {
                    //Computer is down
               }
            }  
        }
    

提交回复
热议问题