Fastest way to test internet connection

前端 未结 6 1683
别那么骄傲
别那么骄傲 2020-11-30 04:03

C# 2008 SP1

I am using this code to connect to our client website. This is for a softphone application. Before the user makes a call, the softphone has to test if th

6条回答
  •  长情又很酷
    2020-11-30 04:52

    A better option is to add reference to the Microsoft.VisualBasic and add a using statement Microsoft.VisualBasic.Device then you can use the following line of code to check for connection to any network at all.

    public static bool isConnectedToNetwork {
       get {
          Network network = new Network();
          return network.IsAvailable;
       }
    }
    

提交回复
热议问题