user99070
user99070

Reputation:

Is there an event that let's me know if an SD Card is mounted? Have to copy several hundred Cards

Is there a Windows Event or mechanism that I can use to know if an SD Card is mounted on a PC running Windows XP/ Vista /7 in C#?

Up to today I found a way to use WM Messages to know if a new Drive is connected and also a way with WQL and they work fine for CD / DVD and USB but none was able to detect if I inserted a SD Card into the PC. This seems to be different from USB Drives and I guess that is because the "Reader" Hardware is already attached to the PC.

But I can't believe that there is no way:(

A bit background to my Question:

I have to copy 800 SD Cards by Hand, that's a one Time thing, and I want to make a little application that starts the copyjob as soon as I insert a card so that you don't have to click any buttons.

Upvotes: 2

Views: 1730

Answers (2)

Michael Heffernan
Michael Heffernan

Reputation: 63

IIRC, Windows 7 has autoplay disabled for all drives except CD/DVD/BD.

Were I you, this is what I would do:

  1. Get a list of files from the target drive (let's assume it's always the same drive) using this: http://www.dotnetperls.com/directory-getfiles
  2. If the list is 0 length (ie, no files) then assume nothing is mounted
  3. If the list is not 0 length, copy files.

Upvotes: 0

MatthiasG
MatthiasG

Reputation: 4532

It's not exactly what you are looking for, but maybe an alternative solution:

There's a guide how to register your app as an auto-play handler on codeproject. You could then check the box telling windows to always use this action and there you go.

Edit:

Another approach would be to use the DriveDetector class also introduced on codeproject. This class will automatically notify you about arrived or removed drives, but I'm not sure if this works for flash cards.

Upvotes: 2

Related Questions