Since .Net 2.0 there's been a NetworkInterface class in the System.Net.NetworkInformation namespace that will give you this information. Try this:
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
if (nic.OperationalStatus == OperationalStatus.Up)
{
Console.WriteLine(nic.GetPhysicalAddress().ToString());
break;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…