Reputation: 13
I am trying to dynamically enumerate the drive letters of USBs as they are connected to my Raspberry Pi running Windows 10 IoT Core.
It is my understanding that I can use Windows.Devices.Enumeration.DeviceWatcher
or DeviceWatcherTrigger
to do this. Once a USB is detected I also want to be able to see if it is empty or, if it isn't, scan for whether it contains a file in a specified directory.
Any help would be greatly appreciated.
Upvotes: 0
Views: 917
Reputation: 2030
Yes, use Windows.Devices.Enumeration.DeviceWatcher to enumerate the portable storage devices on-the-fly, just listen to the Added/Removed/Updated event of DeviceWatcher shall be good enough.
A good tip is if you want to listen to the event in the background(aka, when the foreground app is suspended, you need to handle the Added/Removed/Updated event in a separate windows runtime component, and register the background watcher with Add/Remove/Update event triggers.
Refer to the DeviceEnumerationAndPairing demo project on github for code samples.
Upvotes: 2