So I thought I would include the final answer here so you don\'t have to make sense of this post. Big thanks to Simon Mourier for taking the time to figure this one out.
I've had the same problem and also browsing through the WMI did not help me out, really.
But I ended up with these few lines of code, and it works great for me:
private string GetAvailableStorageDrive()
{
foreach (var info in System.IO.DriveInfo.GetDrives())
{
if (info.DriveType == System.IO.DriveType.Removable &&
info.IsReady &&
!info.Name.Equals("A:\\"))
{
return info.Name;
}
}
return string.Empty;
}
Basically the above function looks if the DriveType
is Removable
andalso if the Drive is ready.
I also exclude the drive letter 'A' because in default windows environments, this is the Floppy.
Description of DriveType.Removable:
The drive is a removable storage device, such as a floppy disk drive or a USB flash drive.
Note: As CodeCaster pointed out, this function will also return removable storage devices such as SATA. So if that's the case, you will have to look into more complex solutions as provided by others.