private string GetMacAddress()
{
const int MIN_MAC_ADDR_LENGTH = 12;
string macAddress = "";
long maxSpeed = -1;
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
string tempMac = nic.GetPhysicalAddress().ToString();
if (nic.Speed > maxSpeed && !String.IsNullOrEmpty(tempMac) && tempMac.Length >= MIN_MAC_ADDR_LENGTH)
{
maxSpeed = nic.Speed;
macAddress = tempMac;
}
}
return macAddress;
}