473,587 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.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*******@ersta ds.com
(sorry for the cross-post - not sure what groups are monitored these
days)

Nov 21 '05 #1
2 4043
Well I dont know if this would work, but you could set a string array
to "Environment.Ge tLogicalDrives" 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
13286
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 comments on past experience, research articles, comments on the matter would be much appreciated. I suspect something like C would be the best based on...
0
1269
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 doesnt exist ???? How do I fix this???? -- Eric Haskins RackSPEED.Net WebHosting from $4.99/month
45
3580
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 themselves are an exception to this), and 'bootstrap' your program by instantiating a single application object in main(), would that place any...
6
5280
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 report any error while writing to the open file handle. On Windows, file shows-up again in explorer and automatically deleted finally when program...
3
3761
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 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).
3
5755
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 drive onto a USB External Hard Drive. I have to assume I also copied the data. I
8
55672
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 everything I've tried, I cannot get MySQL to start as a Windows service. However, I AM able to get it started via the mysqld-nt --console command. Here...
3
3483
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 -- and I want to link to a file (just a .C file) on one of the nfs mounted drives. I'm an html novice and have tried: <p><a...
0
1720
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 the eject button, stop using the drive so that windows can safely remove the hardware. Could someone let me know where to start? what...
7
1374
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 example VB net code that would create buttons on a form dynamically for each drive (cd or HD or virtual etc) found on a system; labeling each created...
0
7915
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.