Skip to content

Instantly share code, notes, and snippets.

@tpund
Created May 3, 2017 18:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tpund/db169916b8da1c7f9513ea2cd80989c5 to your computer and use it in GitHub Desktop.
Save tpund/db169916b8da1c7f9513ea2cd80989c5 to your computer and use it in GitHub Desktop.
Check VPN connection C#
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