How do you determine if an Internet connection is available for your WinForms App?

前端 未结 8 805
生来不讨喜
生来不讨喜 2020-12-24 15:33

What is the best way to determine whether there is an available Internet connection for a WinForms app. (Programatically of course) I want to disable/hide certain functions

8条回答
  •  一生所求
    2020-12-24 15:58

    Ping google.com (or a list of well-known hosts) or try actually performing one of the functions (in a structural sense) for which your application requires Internet connectivity. There is no way, on any operating system, to truly determine whether or not Internet connectivity is functional without actually trying to communicate, as opposed to the operating system's view on what constitutes "available".

提交回复
热议问题