测试网络连接正不正常

Public Shared Function CheckForInternetConnection() As Boolean

    Try

        Using client = New WebClient()

            Using stream = client.OpenRead("https://msdn.microsoft.com/")

                Return True

             End Using

        End Using

    Catch

        Return False

    End Try

End Function

 

posted @ 2015-03-26 11:02  Youjun  阅读(117)  评论(0编辑  收藏  举报