/// <summary>
        /// List all the NetworkAdapters
        /// </summary>
        /// <returns>The list of all NetworkAdapter of the machine</returns>
        public static NetworkAdapter GetNetworkAdapterByDeviceId(int deviceId)
        {
            NetworkAdapter na = null;

            // Manufacturer <> 'Microsoft'to get all none virtual devices.
            // Because the AdapterType property will be null if the NetworkAdapter is
            // disabled, so we do not use NetworkAdapter = 'Ethernet 802.3' or
            // NetworkAdapter = 'Wireless’
            string strWQuery = "SELECT DeviceID, ProductName, "
                               + "NetEnabled, NetConnectionStatus "
                               + "FROM Win32_NetworkAdapter "
                               + "WHERE Manufacturer <> 'Microsoft' "
                               + $" and DeviceID = {0}";

            ManagementObjectCollection networkAdapters = WMIOperation.WMIQuery(strWQuery);

            foreach (ManagementObject moNetworkAdapter in networkAdapters)
            {
                try
                {
                    na = new NetworkAdapter(
                        Convert.ToInt32(moNetworkAdapter["DeviceID"].ToString()),
                        moNetworkAdapter["ProductName"].ToString(),
                        (Convert.ToBoolean(moNetworkAdapter["NetEnabled"].ToString()))
                            ? (int)EnumNetEnabledStatus.Enabled
                            : (int)EnumNetEnabledStatus.Disabled,
                        Convert.ToInt32(moNetworkAdapter["NetConnectionStatus"].ToString()
                                        ));
                }
                catch (NullReferenceException)
                {
                    // Ignore some other devices (like the bluetooth), that need user
                    // interaction to enable or disable.
                }
            }

            return(na);
        }
        /// <summary>
        /// Get the NetworkAdapter Netenabled Property
        /// </summary>
        /// <returns>Whether the NetworkAdapter is enabled</returns>
        public int GetNetEnabled()
        {
            int    netEnabled = (int)EnumNetEnabledStatus.Unknow;
            string strWQuery  = string.Format("SELECT NetEnabled FROM Win32_NetworkAdapter "
                                              + "WHERE DeviceID = {0}", DeviceId);

            try
            {
                ManagementObjectCollection networkAdapters =
                    WMIOperation.WMIQuery(strWQuery);
                foreach (ManagementObject networkAdapter in networkAdapters)
                {
                    netEnabled =
                        (Convert.ToBoolean(networkAdapter["NetEnabled"].ToString()))
                                         ? (int)EnumNetEnabledStatus.Enabled
                                         : (int)EnumNetEnabledStatus.Disabled;
                }
            }
            catch (NullReferenceException)
            {
                // If NullReferenceException return (EnumNetEnabledStatus.Unknow)
            }
            return(netEnabled);
        }