I am new to C# and have to develop a Windows Form application in C#. This application should track the following things.
- Monitor the CD / DVD drives both external and internal.
- Monitor the files which are created, modified and deleted on the CD/DVD drives.
I am able to get system notification for CD/DVD drive insertion by RegisterNotification
and by tracking WM_DEVICECHANGE
messages in the WndProc
method.
The above implementation lets me know when a new device has been attached to the PC.
The problem I am facing is how track the file changes which happen on the CD/DVD (Writes / Modification). One option is to poll for the files in the CD / DVD as a background job. But, this will be as the last option.
I have found IMAPI
through which we can write to CD/DVDs but I just need to monitor the file changes for audit purposes.
Kindly point me to right direction on how to receive file changes on the CD/DVD notification in my program ?
I have tried FileSystemWatcher
but it doesn't seem to work with CD/DVD drives.
Updated on 07-Feb-2018:
The another approach I could find was via WMI
queries which are attached to WMI Events
. I have found a question Best way to detect dvd insertion in drive c#
which could also hold the answer. I wanted to know if the detection of DVD file system modification is feasible in WMI and if any experts can share the query for the same. I hope if Arshad would be able to help in this area.