title: how to refresh management object
body: <p>i had written a code to display the description(Name) of connected USB devices.once i removed a device,then i need to refresh the ManagementObject and have to display the connected device description. </p>
  
  <p>Here is my Code,</p>
  
  <pre><code>ManagementObjectSearcher searcher =
  new ManagementObjectSearcher("SELECT * FROM Win32_USBControllerDevice");
  foreach (ManagementObject mo in searcher.Get())
  {
      string str1 = mo["CurrentRefreshRate"].ToString();
      Console.WriteLine(str1);
      string dependent = mo["Dependent"].ToString();
      string deviceId = dependent.Split('=')[1];
      deviceId = deviceId.Replace('\"', '\'');
      ManagementObjectSearcher searcher2 =
      new ManagementObjectSearcher("SELECT * FROM Win32_PnPEntity Where DeviceID = " + deviceId);
      foreach (ManagementObject mo2 in searcher2.Get())
      {
          HardwareDetails Detail = new HardwareDetails();               
          Detail.Description = mo2["Description"].ToString();
          Detail.DeviceId = mo2["DeviceId"].ToString();
          string[] str = Detail.DeviceId.Split('\\');
          string Id = str[1];
          if (Id.Contains('&amp;'))
          {
              string[] separate = Id.Split('&amp;');
              Detail.Vid = separate[0].Contains('_') ? separate[0].Split('_')[1] : separate[0].Split('D')[1];
              Detail.Pid = separate[1].Contains('_') ? separate[1].Split('_')[1] : separate[1].Split('D')[1];
              //Detail.Pid = pid1[1];               
          }
          else
          {
              Detail.Vid = "";
              Detail.Pid = "";
          }
          if (list.Count &gt; 0)
          {
              foreach (HardwareDetails h in list)
              {
                  if (!(h.Description == Detail.Description))
                  {
                      list.Add(Detail);
                      break;
                  }
              }
          }
          else
              list.Add(Detail);                
      }
  }
  // remove duplicates, sort alphabetically and convert to array
  HardwareDetails[] usbDevices = list.ToArray();
  return usbDevices;
  </code></pre>