判断是否连接网络

private bool IsInternetAvailable()
{
    try
    {
        Dns.GetHostEntry("www.google.com"); //using System.Net;
        return true;
    } catch (SocketException ex) {
        return false;
    }
}

 

posted on 2017-01-18 20:11  武胜-阿伟  阅读(249)  评论(0编辑  收藏  举报