Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 800447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:17:36+00:00 2026-05-14T23:17:36+00:00

I am writing a piece of software in C# using .NET 2 which detects

  • 0

I am writing a piece of software in C# using .NET 2 which detects whether there is an active ethernet connection on the Windows machine.

It is important that it knows that it is ethernet rather than WiFi as the program will behave differently depending on whether sending data with a WebClient is going over WiFi or Ethernet.

I have tried using System.Net.NetworkInformation.NetworkInterfaceType but this seems to report ‘Ethernet’ for a lot of WiFi cards.

Any suggestions will be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:17:36+00:00Added an answer on May 14, 2026 at 11:17 pm

    According to this MSDN page about the NetworkInterface.NetworkInterfaceType property,

    This property only returns a subset of
    the possible values defined in the
    NetworkInterfaceType enumeration. The
    possible values include the following:

    Ethernet Fddi Loopback Ppp Slip TokenRing Unknown

    So deterministically you may be SOL.

    However, you may be able to perform some heuristics on the available network connections, to determine if they are WiFi or cable. These might include ping response/latency times taken over many iterations, etc.

    Also, the speed of the adapter might be used as a hint. For my WiFi adapter the speed is always shown as “54000000” (e.g. 54 mbs). Since there is a set of common WiFi speeds, this could be helpful.

    Perhaps the following code might get you started:

    using System;
    using System.Net.NetworkInformation;
    using System.Net;
    
    namespace ConsoleApplication7
    {
        class Program
        {
            static void Main(string[] args)
            {
                NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
                Ping pingObj = new Ping();
    
                for (int i = 0; i < adapters.Length; i++)
                {
                    Console.WriteLine("Network adapter: {0}", adapters[i].Name);
                    Console.WriteLine("    Status:            {0}", adapters[i].OperationalStatus.ToString());
                    Console.WriteLine("    Interface:         {0}", adapters[i].NetworkInterfaceType.ToString());
                    Console.WriteLine("    Description:       {0}", adapters[i].Description);
                    Console.WriteLine("    ID:                {0}", adapters[i].Id);
                    Console.WriteLine("    Speed:             {0}", adapters[i].Speed);
                    Console.WriteLine("    SupportsMulticast: {0}", adapters[i].SupportsMulticast);
                    Console.WriteLine("    IsReceiveOnly:     {0}", adapters[i].IsReceiveOnly);
                    Console.WriteLine("    MAC:               {0}", adapters[i].GetPhysicalAddress().ToString());
                    if (adapters[i].NetworkInterfaceType != NetworkInterfaceType.Loopback)
                    {
                        IPInterfaceProperties IPIP = adapters[i].GetIPProperties();
                        if (IPIP != null)
                        {
                            // First ensure that a gateway is reachable:
                            bool bGateWayReachable = false;
                            foreach (GatewayIPAddressInformation gw in IPIP.GatewayAddresses)
                            {
                                Console.WriteLine("    Gateway:     {0} - ", gw.Address.ToString());
    
                                // TODO: Do this many times to establish an average:
                                PingReply pr = pingObj.Send(gw.Address, 2000);
    
                                if (pr.Status == IPStatus.Success)
                                {
                                    Console.WriteLine("    reachable ({0}ms)", pr.RoundtripTime);
                                    bGateWayReachable = true;
                                    break;
                                }
                                else
                                    Console.WriteLine("    NOT reachable");
                            }
                            // Next, see if any DNS server is available. These are most likely to be off-site and more highly available.
                            if (bGateWayReachable == true)
                            {
                                foreach (IPAddress ipDNS in IPIP.DnsAddresses)
                                {
                                    Console.WriteLine("    DNS:         {0} - ", ipDNS.ToString());
                                    PingReply pr = pingObj.Send(ipDNS, 5000); // was 2000, increased for Cor in UK office
                                    if (pr.Status == IPStatus.Success)
                                    {
                                        Console.WriteLine("    reachable ({0}ms)", pr.RoundtripTime);
                                        Console.WriteLine("    --- SUCCESS ---");
                                        break;
                                    }
                                    else
                                        Console.WriteLine("    NOT reachable");
                                }
                            }
                        } // if (IPIP != null)
                    }
                } // foreach (NetworkInterface n in adapters)
    
                Console.ReadLine();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a piece of open-source software which will be easily embeddable (both static/dynamic
While i was writing a piece of code in C# using ASP.NET i needed
There is an input file to a piece of software I am writing. This
I'm writing a piece of software using RealBASIC 2011r3 and need a reliable, cross-platform
I am writing a piece of small software to go through the folders and
I'm writing my first proper useful piece of software. Part of it will involve
I'm writing a plug-in for a piece of software that takes a big collection
If I was writing a piece of software that attempted to predict what word
I'm writing a piece of simulation software, and need an efficient way to test
I am writing a piece of software in C++ RAD studio 2010 and got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.