0
votes

I want to get MAC address of both Wireless network adapter and the ethernet adapter of a computer by using C#. I came across NetworkInterface.GetPhysicalAddress method (http://msdn.microsoft.com/en-us/library/system.net.networkinformation.physicaladdress%28v=vs.110%29.aspx) but I am not sure whether it will return both the address (wireless/ethernet) or any one address. Can someone clarify this and can you also provide a code snippet which is actually capable of fetching both the addresses if they exist in the computer (i.e. if both the adapters are present in the computer)

1
I am not sure whether it will return both the address - why not try and see?! can you also provide a code snippet - why not try example from your linked documentation Examples section?Renatas M.
It will get you the MAC address of the network adapter it refers to, i.e. you need an instance of NetworkInterface for each adapter. The MSDN article you link to shows you how to get the mac adressess of all the network adapters in the machine.Ben Robinson

1 Answers

1
votes

Just try

var networks = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();

Below attached array printout, notice NetworkInformationType field.

enter image description here