简体   繁体   中英

How to detect MTP device and start copying files?

I have a VB app which currently detects when external drives are added (which get drive letters), and begins copying certain files from them. Pretty handy, to just plug in a camera (say) and my app extracts the files it needs (optionally deleting from the external device).

Some devices, oh let's say GoPro Hero4's, do not mount with drive letters, but show up as MTP devices. My code does not detect that, and that's what I'd like guidance on.

Should I be using the 'StorageDevice' class? Some WMI thing? WDP?

It 'seems'like StorageDevice contains what I need, but the docs are kinda high-level and I'm looking for a solid example, preferably in VB or C#. Any suggestions for the best solution?

Edit: Thanks for the link to other management q&a but I think this is somewhat different in a) I'd like to detect device connected events, not just copy files, and b) the links on that other q&a lead to projects which are sparsely documented. Maybe the answer IS there, but I'm trying to just get an answer, not dig through source code which may or may not be what I need.

I haven't tried it, but this discusses why there's no "device connected" event and how to detect and handle device connections.

The Plug and Play interface is used to detect connected devices.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM