Results 1 to 3 of 3

Thread: Detect file in usb device

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2004
    Posts
    59

    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

  2. #2
    Addicted Member bgard68's Avatar
    Join Date
    Mar 2006
    Location
    Arkansas
    Posts
    164

    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.
    Attached Files Attached Files
    Using Framework 1.1, VB.Net 2003 unless I
    state otherwise

  3. #3
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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
    Last edited by gigemboy; Mar 22nd, 2006 at 09:00 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width