This question has been asked to death but i cannot take from those answers what my problem is.
All i want to do is :
- Declare my global bool variable (used as a flag for later.)
- Run my method to do a check, in which it will change the global variable
Anybody able to explain why this isn't working? Thanks.
class Program
{
public bool onVPN;
static void Main(string[] args)
{
CheckVPN();
CheckIfInternal();
Console.WriteLine("Press enter to close...");
Console.ReadLine();
}
public void CheckVPN()
{
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
//crude way to check if the VPN adapter is running
if (adapter.Description == "VPN Adapter")
{
onVPN = true;
}
else
{
onVPN = false;
}
}
}