I\'m writing a program in C# that needs to monitor the amount of internet bandwidth currently in use so it can do a background upload when the internet usage is low. How ca
use below code snippet for get the current active network adapter.
using System.Net.NetworkInformation;
using System.Linq;
class Program
{
static void Main(string[] args)
{
NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces().FirstOrDefault(o => o.OperationalStatus == OperationalStatus.Up && o.NetworkInterfaceType != NetworkInterfaceType.Tunnel && o.NetworkInterfaceType != NetworkInterfaceType.Loopback);
if (networkInterface != null)
{
Console.WriteLine(networkInterface.Name);
}
}
}