Catching 'external drive inserted' event in a windows service
-
02-07-2019 - |
Question
I'm trying to write a super-simple podcast-to-device downloading service to use for running. I imagine that it'll like this:
Whenever a particular device is plugged in (via USB), it:
- Deletes everything from the device
- Checks for all the latest entries in a number of RSS Podcast feeds
- Downloads those to the device
- Notifies the user about when its done.
I have some passing experience with windows services, but am not sure how to (using .NET/C#) catch the 'media device/usb hard drive has been plugged in' event. Any advice?
Solution
The simplest solution would be to periodically enumerate the devices!
CodeProject has a comprehensive C# article for this here : http://www.codeproject.com/KB/system/DriveDetector.aspx
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow