我希望能够读取第一个活动的网络适配器使用VB.net或C#(使用.NET 3.5 SP1)的WinForm应用程序的mac地址
I'd like to be able to read the mac address from the first active network adapter using VB.net or C# (using .NET 3.5 SP1) for a winform application
由于NET 2.0也一直在给你这些信息的System.Net.NetworkInformation命名空间NetworkInterface类。试试这个:
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;
}
}