First of all, it very well could be that I'm approaching my problem the wrong way, in which case I'd gladly accept alternatives.
What I'm trying to achieve is to detect which drive was created after a USB device has been connected to a computer.
Here is the simplified workflow:
// Get list of removable drives before user connects the USB cable
List<string> listRemovableDrivesBefore = GetRemovableDriveList();
// Tell user to connect USB cable
...
// Start listening for a connection of a USB device
...
// Loop until device is connected or time runs out
do
{
...
} while
// Get list of removable drives after USB device is connected
List<string> listRemovableDrivesAfter = GetRemovableDriveList();
// Find out which drive was created after USB has been connected
???
GetRemovableDriveList
returns a list of strings of the removable drive letters.
My idea was to get a list of removable drives before the device is connected, and another list after it is connected, and that by removing the contents of the first list from the second, I would be left with drives that were just connected (normally only one).
But I can't find a simple way of "subtracting" one list from another. Anyone could suggest a solution, or even a better way of achieving what I'm trying to do.
Note: project is targeting the .NET framework 2.0, so no LINQ possible.
Thanks!