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; }