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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.