I would like detect and act when a spesific mp3 file is used(played as an alarm in another application) in c#.
Waiting for ideas, Thanks all.
Windows does not update the lastaccesstime when a file is opened for reading, so that cannot be used.
There are two ways I can think of doing this, but both involving polling the system.
Loop every X seconds and try to open the file for write. If this fails then the file is open.
Loop every X seconds and use a WMI Query to see if the file is in use.
Either way, you will then have to handle consecutive "opens" within a certain period of time count as only a single instance.