MAC address reading

Juan

Member
Joined
Dec 25, 2018
Messages
8
Programming Experience
Beginner
Hello,
C#:
using System;using System.Collections;
using System.Management;
using System.Net.NetworkInformation;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Win32;


    class Program
    {
        public static void Main(string[] args)
        {


            string resultado = string.Empty;
             resultado = GetMacAddress();
            Console.Write("Press any key to continue . . . ... ");
            Console.ReadKey(true);
        }


      public static string GetMacAddress()
        {
            string text = "";
            NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface networkInterface in allNetworkInterfaces)
            {
                PhysicalAddress physicalAddress = networkInterface.GetPhysicalAddress();
                text += physicalAddress.ToString();
            }
             
          return text;
        }


       
        }

I wonder what is the problem?
 
yes I can see it now . :)
Look like this code is reading all MAC addresses even which belongs to virtual interfaces.
 
Last edited:
Back
Top Bottom