Detect file in usb device
Hi
Anyone know how i can detect when a usb device is plugged in. when the device is plugged in should check to see if the following file exists in the device:
thefile.txt
If this file exists it should show a message box. If it does not exist it should do nothing.
Anyone know how to do this?
Thanks
1 Attachment(s)
Re: Detect file in usb device
Check out:
1. http://www.microsoft.com/communities...213191b3e1&p=1
2. http://www.vb-tips.com/default.aspx?...a-07a4ef9d9504
Also, check out this demo program, it doesnt do everything - but it does
detect when you stick in a usb drive.
You need to verify there is a reference to the system.management namespace as well.
Re: Detect file in usb device
you can use the Win32_LogicalDisk WMI class and check for DriveType of "2" which is removable disk. This will also pull up floppy disk drives, and to not include those, you can also check for the MediType property, if it equals "0", then the media is unknown. If a floppy drive, the media type will be found, and not return 0... (at least, this was tested on my USB drive)
You can check out my sig for the WMI codebank submission for an example of using WMI...
And the documentation of the Win32_LogicalDisk class
http://msdn.microsoft.com/library/de...ogicaldisk.asp