Checking network status in C#

后端 未结 7 1900
时光取名叫无心
时光取名叫无心 2020-11-30 05:05

How do I check that I have an open network connection and can contact a specific ip address in c#? I have seen example in VB.Net but they all use the \'My\' structure. Than

7条回答
  •  有刺的猬
    2020-11-30 05:42

    You can check network status using

    if(System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
    {
      //Do your stuffs when network available
    
    }
    else
    {
     //Do stuffs when network not available
    
    }
    

提交回复
热议问题