Author Topic: How to mount programmatically a vendor specific device to copy its files ?  (Read 3861 times)

Golgo1972

  • Member
  • ***
  • Posts: 9
I have tried using winusbdemo_cs using the WinUSBDemo to do a bulk read off of a vendor specific body camera usb device but I only get timeouts. Also the files stored on the body cam are of the following:

.jpeg for photos taken stored on the device, .mov files for movies stored on the device and .mp3 files for audio recorded on the device.

How can I programmatically mount the device and the read off of the mount path (M):/directory-to-files/audio || or video || or jpeg ?

I saw some code from a blog that does this:

 public string[] getLogicalUsbDisks()
        {
            int i = 0;

            string[] lista;
            Console.WriteLine("fetching logical disks...");

            try
            {
                ManagementObjectCollection drives = new ManagementObjectSearcher(

                "SELECT Caption, DeviceID FROM Win32_DiskDrive WHERE InterfaceType='USB'").Get();



                lista = new string[drives.Count];

                // browse all USB WMI physical disks

                foreach (ManagementObject drive in drives)
                {
                    // browse all USB WMI physical disks

                    foreach (ManagementObject partition in new ManagementObjectSearcher(

                    "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='"

                    + drive["DeviceID"]

                    + "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition").Get())

                    {

                        // browse all USB WMI physical disks

                        foreach (ManagementObject disk in new ManagementObjectSearcher(

                        "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='"

                        + partition["DeviceID"]

                        + "'} WHERE AssocClass = Win32_LogicalDiskToPartition").Get())

                        {
                            lista = disk["CAPTION"].ToString();

                            i++;
                        }
                    }

                }

                return lista;
            }

            catch (Exception e)
            {
                Console.WriteLine("error: " + e.ToString());
                return null;
            }
        }

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
If these are files in a directory structure, Windows should assign the mass-storage driver to the device by default, and you can then use the .NET File class or other APIs to copy the files.