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 8074923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:49:23+00:00 2026-06-05T14:49:23+00:00

I wrote code to populate a menu with the available IPv4 NICards on a

  • 0

I wrote code to populate a menu with the available IPv4 NICards on a machine. It has been tested on an XP machine and it seems all fine and well (it was also built on XP).

I had it tested on Windows 7 and it always populated 2 IP address even if one was disconnected. Here are the results for the Win7 machine:

WLAN Connected
LAN Disconnected

Observed: Correct WLAN address shows, Incorrect LAN address shows (it is even a different network number where it’s connected to 192.168 however the LAN address that is populated in the menu is 169.254)
Expected: Correct WLAN address shows, No LAN shows (it is disconnected)
ipconfig reads “Media disconnected” for LAN

WLAN Connected
LAN Connected

Observed: Correct WLAN address shows, Correct LAN address shows
Expected: Correct WLAN address shows, Correct LAN address shows

ipconfig reads correct address

WLAN Disconnected
LAN Connected

Observed: Correct WLAN address shows, Correct LAN address shows
Expected: No WLAN address shows(it is disconnected), Correct LAN shows
ipconfig reads “Media disconnected” for WLAN

Here is the code block:

_adapters.Clear();
if (NetworkInterface.GetIsNetworkAvailable())
{
    NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();

    foreach (NetworkInterface adapter in networkInterfaces)
    {
        foreach (UnicastIPAddressInformation addr in adapter.GetIPProperties().UnicastAddresses)
        {
            //This filters out IPv6 and Loopback NICs
            if (addr.Address.AddressFamily == AddressFamily.InterNetwork
                && adapter.NetworkInterfaceType != NetworkInterfaceType.Loopback) 
            {    //This formats something like: 192.168.1.0 - Ethernet adapter Local Network Connection
                _adapters.Add(addr.Address.ToString() + " - " + adapter.NetworkInterfaceType.ToString() + " adapter " + adapter.Name);
            }
        }
    }
}

Using 4.0 .NET on VS2010 for what its worth

  • 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-06-05T14:49:25+00:00Added an answer on June 5, 2026 at 2:49 pm

    To see if a NIC is connected or not you should check the NetworkInterface.OperationalStatus property.

    The “strange” IP address when LAN is disconnected comes from APIPA (Automatic Private IP Addressing). A “feature” introduced with Windows Vista:

    …a feature in Windows Vista to automatically configure itself with an IP address and subnet mask when a DHCP server isn’t available. The IP address range is 169.254.0.1 through 169.254.255.254, a range that has been reserved especially for Microsoft.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been doing a bit of testing on some code I wrote when I
Disclaimer: It's been a while since I last wrote any code. The quality of
i added sharekitkit my project. And wrote code like here : SHKItem *item =
I wrote my code using this article at msdn as a primary helper My
I wrote some code to read a file in my Java Servlet class. (I'm
I wrote a code to show a div element(shareform) when a link is clicked
I wrote a code sometime ago in which the object of ResultSet class res
i wrote following code to create a linkbutton programmatically, but its showing like lable
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
I wrote the code below : 1. MyClass[] origArr=new MyClass[3]; 2. MyClass[] arr1; 3.

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.