Get Mac Address List - CSharp Network

CSharp examples for Network:IP Address

Description

Get Mac Address List

Demo Code

// All Rights Reserved , Copyright (C) 2012 , Hairihan TECH, Ltd. 
using System.Net.NetworkInformation;
using System.Net;
using System.Management;
using System.Collections.Generic;

public class Main{

        public static List<string> GetMacAddressList()
        {/* www  .  j  a  v a2  s.  c o m*/
            List<string> macAddressList = new List<string>();
            NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface ni in networkInterfaces)
            {
                if (!ni.Description.Contains("WiFi") && !ni.Description.Contains("Loopback") && !ni.Description.Contains("VMware") && ni.OperationalStatus == OperationalStatus.Up)
                {
                    macAddressList.Add(ni.GetPhysicalAddress().ToString());
                }
            }
            return macAddressList;
        }
}

Related Tutorials