Tuesday 8 February 2022

Retrieve Client PC MAC address

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Management;
using System.Net.NetworkInformation;
using System.IO;

public string GETMAC()
        {
            string macadd = "";
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            PhysicalAddress address = nics[0].GetPhysicalAddress();
            byte[] bytes = address.GetAddressBytes();
            for (int i = 0; i < bytes.Length; i++)
            {
                macadd += bytes[i].ToString("X2");
                if (i != bytes.Length - 1)
                {
                    macadd += ":";
                }
            }
            return macadd;
        }

No comments:

Post a Comment

Upload valid file in C#

    protected bool CheckFileExtandLength(HttpPostedFile HtmlDocFile)     {         try         {             Dictionary<string, byte[]>...