Question Detecting a 3G connection in Windows 7 and 8 in a desktop application

redserpent7

New member
Joined
Dec 24, 2012
Messages
1
Programming Experience
3-5
I am in the process of developing a cloud backup software. The application is a desktop application developed using C#.
I need to add an option to stop/pause the backup if the computer was connected to a 3G network to save cost for the user.
I cannot seem to be able to find any example on how this can be achieved, there are some examples for Windows Phone and Windows Store Apps but I cannot find anything that can check if the connection type is a WiFi/Ethernet or 3G the latter is my main concern.
I tried a test application to enumerate the networks:
C#:
Console.WriteLine("checking network interfaces\n");
    
    NetworkInterface[] interfaces =  NetworkInterface.GetAllNetworkInterfaces();
    
    foreach (var networkInterface in interfaces)
    {
       Console.WriteLine("Interface Detected");
       Console.WriteLine("Description: "+networkInterface.Description);
       Console.WriteLine("ID: " + networkInterface.Id);
       Console.WriteLine("Name: " + networkInterface.Name);
       Console.WriteLine("Interface Type: " + networkInterface.NetworkInterfaceType);
       Console.WriteLine("Operational Status: " + networkInterface.OperationalStatus.ToString());
       Console.WriteLine("Speed: " + networkInterface.Speed.ToString());
       Console.WriteLine("Supports Multicast: " + networkInterface.SupportsMulticast.ToString());
       Console.WriteLine("#########################################################\n");
    }

The above code list my 3G connection as PPP which can be either ADSL or 3G. I am not sure if I can differentiate using some other options or APIs
I need a clear way to distinguish between those networks and so far I cannot find a way of doing so.
Can someone please help?
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,138
Location
Sydney, Australia
Programming Experience
10+
I don't know the answer to your question but, as noone else seems to either, I will suggest that the most likely way to discover information like that would be using WMI, which is used via the System.Management namespace. That will give you something to investigate.
 
Top Bottom