顶部信息栏,显示网站标题、Logo等资

How to get MAC Address

1/24/2015 Source:Backyard [comment]


public string GetMacAddressByNetworkInformation()  
{  
    string macAddress = "";  
    try  
    {  
        NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();  
        foreach (NetworkInterface adapter in nics)  
        {  
            if (!adapter.GetPhysicalAddress().ToString().Equals(""))  
            {  
                macAddress = adapter.GetPhysicalAddress().ToString();  
                for (int i = 1; i < 6; i++) { macAddress = macAddress.Insert(3 * i - 1, ":"); } break; } } } catch { } return macAddress; }