使用 WinForm 应用程序检测是否检测到任何 USB 驱动器
我想在我的应用程序中执行以下操作
1) 我想在我的应用程序中显示是否插入了 USB 驱动器,以提示用户插入 USB 驱动器。我只是想通知用户是否插入了任何 USB 驱动器,否则提示他使用标签或其他东西插入一个(我想避免消息框,因为每当插入或删除设备时它都会不断出现。这最终会让人恼火用户)在我的 Visual C# WinForm 应用程序中。如果存在任何 USB 驱动器,则会在标签中显示“检测到 USB 驱动器”。用户可以添加一个或多个 USB 记忆棒,但状态将保持不变。如果没有,标签的状态将更改为“未找到 USB 驱动器。请插入 USB 驱动器”。
2) 添加一个或多个 USB 驱动器时,带有驱动器盘符的卷名称(例如“James(F:)”)将添加到组合框列表中。组合框列表还需要在删除时自动删除添加到列表中的 USB 驱动器的条目。因此,当没有 USB 时,列表应为空,标签将再次提示用户插入 USB 记忆棒或驱动器。
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 inserted 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这篇 CodeProject 文章中的代码演示了您想要执行的大部分操作:
枚举和自动检测USB 驱动器
我想您会发现它很有用。
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.