Getting all available network interface using NetworkInterface namespace

By using the NetworkInformation namespace
you can get all of the available network interfaces on the current machine.
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.aspx
This is very useful for  applications that are network aware 
or that require to configure the network adapters.
 
using System.Net.NetworkInformation;
 
   1:  //Iterate to all available network interfaces
   2:  foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces())
   3:  {
   4:      // Filter to load only configurable interfaces
   5:      if (netInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet |
   6:           netInterface.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
   7:      {
   8:         //Use the ff as strings, add to a collection or a list
   9:          netInterface.Name.ToString();
  10:          netInterface.Description.ToString();
  11:      }
  12:  }

The above snippet came from a little project that I wrote for me and my Amy that configures our wireless and cabled adapters. Because we both have laptops that connects to both of our office wireless, LAN on their conference (no wireless signal there), wireless in the condo, wireless at Bataan (ssshhh its free, but we need to configure your DNS to SMART BRO :P, it seems that their neighbor has DHCP but did not configured / or has hidden the DNS) 

Advertisements

Published by

johndelizo

I'm John and in the daytime I am the Chief Technology Officer of VFTS.NET - a consulting firm that specializes on development and deployment of business solutions created with .NET framework on Windows platform and Windows infrastructure projects. I am a core member of the Philippine Windows Users Group, a contributor at the Microsoft Philippines Community forums and I regularly conduct technical sessions as well as other Microsoft technology events. I am a Microsoft Most Valuable Professional in the Cloud and Datacenter Management Technical Expertise but away from any keyboard I spend hours reading books, travel, explore, and being busy with my dog named Floppy.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s