One of the ways to identify the thumb drive is using WMI.
You can look at my PowerShell scrip and use it as a pseudo-code:
$removable = Get-WmiObject CIM_StorageVolume$r | where { $_.driveType -eq 2 }
foreach ($drive in $removable) {
# use $drive.Name,
# $drive.Label
# $drive.DeviceID
# ...
}
The "type" 2 corresponds to "removable drive". Optical media is not considered "removable", so, in practice you will traverse the set of your USB drives and, perhaps, embedded card reader.
For the documentation on the WMI class please see:
CIM_StorageVolume class (Windows)[
^].
You also need to learn how to use WMI via .NET. The idea is: you don't use the classes like directly
CIM_StorageVolume
. You pass then name of this class as a string to
System.Management API
. For example, in your case, you obtain the WMI class instance via the constructor call:
new ManagementClass("CIM_StorageVolume")
.
You can start here:
WMI .NET Overview[
^].
This is the rudimentary code sample, unrelated to your problem. I just wanted to give you the idea on how API is used:
A Simple System.Management Application[
^].
—SA