PingTool.cs 820 B

12345678910111213141516171819202122232425262728
  1. //************************************************************************
  2. // author: yuzhengyang
  3. // date: 2018.3.27 - 2018.6.3
  4. // desc: 工具描述
  5. // Copyright (c) yuzhengyang. All rights reserved.
  6. //************************************************************************
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Net.NetworkInformation;
  11. using System.Text;
  12. namespace Azylee.Core.NetUtils
  13. {
  14. public class PingTool
  15. {
  16. public static bool Ping(string ip)
  17. {
  18. try
  19. {
  20. Ping _ping = new Ping();
  21. PingReply _reply = _ping.Send(ip);
  22. return _reply.Status == IPStatus.Success ? true : false;
  23. }
  24. catch { return false; }
  25. }
  26. }
  27. }