Created
May 3, 2017 18:17
-
-
Save tpund/db169916b8da1c7f9513ea2cd80989c5 to your computer and use it in GitHub Desktop.
Check VPN connection C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (NetworkInterface.GetIsNetworkAvailable()) | |
{ | |
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces(); | |
foreach (NetworkInterface Interface in interfaces) | |
{ | |
if (Interface.OperationalStatus == OperationalStatus.Up) | |
{ | |
if ((Interface.NetworkInterfaceType == NetworkInterfaceType.Ppp) && (Interface.NetworkInterfaceType != NetworkInterfaceType.Loopback)) | |
{ | |
IPv4InterfaceStatistics statistics = Interface.GetIPv4Statistics(); | |
MessageBox.Show(Interface.Name + " " + Interface.NetworkInterfaceType.ToString() + " " + Interface.Description); | |
} | |
else | |
{ | |
MessageBox.Show("VPN Connection is lost!"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment