Example #1
0
 public USBSync(string rootDir)
 {
     USBDevice = new USBDeviceInfo
     {
         Name = rootDir
     };
 }
Example #2
0
        public static IEnumerable <USBDeviceInfo> GetUsbDevices()
        {
            var list = new List <USBDeviceInfo>();

            foreach (var device in new ManagementObjectSearcher(@"SELECT * FROM Win32_DiskDrive WHERE InterfaceType LIKE 'USB%'").Get())
            {
                foreach (var partition in new ManagementObjectSearcher(
                             "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" + device.Properties["DeviceID"].Value
                             + "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition").Get())
                {
                    foreach (var disk in new ManagementObjectSearcher(
                                 "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='"
                                 + partition["DeviceID"]
                                 + "'} WHERE AssocClass = Win32_LogicalDiskToPartition").Get())
                    {
                        var dir    = disk["Name"].ToString();
                        var volume = disk["VolumeName"].ToString();
                        var d      = new USBDeviceInfo {
                            Name = dir, VolumeName = volume
                        };
                        list.Add(d);
                    }
                }
            }

            return(list);
        }
Example #3
0
 public USBSync(USBDeviceInfo device)
 {
     USBDevice = device;
 }