Question about rootDirectory of USB Host

Why the rootDirectory of USB Host is “\SD”?

I have as follow test codes:



main()
{
            //USB stick detection
            USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;
            USBHostController.DeviceDisconnectedEvent += DeviceDisconnectedEvent;
}

        //USB stick connected
        static PersistentStorage ps;
        static void DeviceConnectedEvent(USBH_Device device)
        {
            if (device.TYPE == USBH_DeviceType.MassStorage)
            {
                Debug.Print("USB Mass Storage detected...");
                Debug.Print("Device connected...");
                Debug.Print("ID: " + device.ID + ", Interface: " +
                            device.INTERFACE_INDEX + ", Type: " + device.TYPE);

                ps = new PersistentStorage(device);
                ps.MountFileSystem();
                string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
                Debug.Print(rootDirectory);                        

            } 

        }

        //USB stick disconnected
        static void DeviceDisconnectedEvent(USBH_Device device)
        {
            Debug.Print("Device disconnected...");
            Debug.Print("ID: " + device.ID + ", Interface: " +
                        device.INTERFACE_INDEX + ", Type: " + device.TYPE);
        }

I use SD card too, the rootDirectory of SD card is also “SD/”, How can I differentiate the 2 rootDirectory?

I want to access USB stick and SD card.

VolumeInfo.GetVolumes()[0].RootDirectory
VolumeInfo.GetVolumes()[1].RootDirectory

which is which depends on the mount order.

I personaly use

if (VolumeInfo.GetVolumes()[0].Name == “SD”)
if (VolumeInfo.GetVolumes()[0].Name == “USB”)

to see whitch is SD and USB

1 Like

@ David@ Emrol -

ok! I got it! thank you very much!