Detect if any USB drive is detected or not using WinForm Application
I want to do the following things in my application
1) I want to display whether any USB drive is inserted or not in my application to prompt the user to insert a USB drive. I just want to notify the user if any USB dirve is inse开发者_如何学编程rted else prompt him to insert one using a label or something (i want to avoid messagebox as it will keep appearing whenever a device is inserted or removed. It will be irritating for the end user) in my Visual C# WinForm Application. If any USB drive is present display "USB drive detected" in the label. The user may add one or more USB sticks but the status will remain same. When there is none then the status of the label will change to "No USB drives found.Please insert a USB drive".
2) When one or more USB drive is added the volume name with the drive letter for example "James(F:)" is added to the Combobox list. The combobox list also needs to remove the entry for the USB drive added in the list automatically when it is removed . So when there is no USB the list should be empty and the label will again prompt user to insert a USB stick or drive.
The code in this CodeProject article demonstrates much of what you want to do:
Enumerate and Auto-Detect USB Drives
I think you'll find it useful.
精彩评论