473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

.Net code to Detect When an External Drive is Mounted?

Hi,

I'm looking for some code to monitor for when an external drive is
connected to a computer (USB ThumbDrive, External Hard Drive, etc.) and
is assigned a drive letter.

I'd want my code to trigger off of the mounting process so I can search
for a specific file on that hard drive (which is always guaranteed to
be in a specific spot).

Is this a Windows Event I can attach to?

Either Vb.net or C# code would be extremely helpful.

Thanks,
Sp*******@erstads.com
(sorry for the cross-post - not sure what groups are monitored these
days)

Nov 21 '05 #1
2 4026
Well I dont know if this would work, but you could set a string array
to "Environment.GetLogicalDrives" and then you can store the length of
the array (number of drives). Once the length of the array changes,
you know another drive letter has been added.

This isn't an Event though, but might give you some other ideas.
Hope this helps.

Nov 21 '05 #2


I actually found a couple of good resources on trapping for the event.
Here's some good C# code to detect when a USB device is attached:

http://www.codecomments.com/archive2...-4-185490.html

Works pretty well.

I will probably use your trigger to loop through the drives though - I'm
looking for one specific file when an Ipod is connected to the computer.

Thanks for the reponse.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
0
by: Eric Haskins | last post by:
I had a server lose a drive. This customer didnt back his database. I mounted old failing drive as a slave and can see .frm .MYI & .MYD But if I copy them to /var/lib/mysql/db_name it says .frm...
45
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes...
6
by: Kiran | last post by:
Hi, I have program, which opens file at the startup and logs error messages to the file, file handle is closed at the end of the program. However if file is deleted in-between, program do not...
3
by: Sped | last post by:
Hi, I'm looking for some code to monitor for when an external drive is connected to a computer (USB ThumbDrive, External Hard Drive, etc.) and is assigned a drive letter. I'd want my code to...
3
by: eieiohh | last post by:
MySQL 3.23.49 PHP 4.3.8 Apache 2.0.51 Hi All! Newbie.. I had a CRM Open Source application installed and running. Windows Xp crashed. I was able to copy the contents of the entire hard...
8
by: Kevin D. | last post by:
Please note, I already posted this on the MySQL official forum, but received no response. I thought I'd try again in another location. My apologies to anyone reading this twice... Despite...
3
by: shardy | last post by:
Hello, I am trying to create a code repository for myself and am having trouble linking to files. Basically, the web server computer has drives from several other computers nfs mounted to it --...
0
by: D2 | last post by:
Hi, I'm working on a C# windows service that should detect when a USB drive is plugged in. After drive letter has been assigned, start using that drive. On the other side, when user clicks on...
7
by: Malakie | last post by:
Hi all, I am trying to self teach VB .net to myself. Not sure what is worse, trying to accomplish this or thinking I can actually do it! ;-) Anyhow, Would someone be able to give me some...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.