Thread: Detect when a file is used

  1. #1
    Registered User
    Join Date
    Oct 2008

    Detect when a file is used

    I am not sure if this question should be here but what I wonder is if this is possible:
    I have a mp3-file like this. "D:\\music\\song.mp3".
    Now if I will play this song with example VLC-player, this meens that the mediaplayer accessing the file.

    My question is if it is possible to detect when this file is used/played and if it is possible to return the fullpath for the file when it happens ?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    There is no easy way of doing this. You could write a filter driver, but it is A LOT of effort.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Oct 2008
    okay, I have to ask. I wonder if the fileSystemWatcher component in the form application can do this. I have have tried this component out with these events:


    But when accessing the file wich should be in this case, no of these event could be used for this as I have tried out ?

    Under the properties of this component there is a "NotifyFilter" that for example has "LastAccess" wich perheps could be it but I have not got it to work there.
    With the changed event I have tried it out to open the file in "Notepad" as a test and change a few characters and saved the file and this returns me the Full Path of the file. It works fine.

    I wonder if the "LastAccess" could be something to use in any way.

  4. #4
    Registered User
    Join Date
    Oct 2008
    This was strange, suddenly it works with the _Changed event and NotifyFilter "LastAccess".
    The Watcher detects the file and full path when using the testcode like this.
    I will try to test it out.

    private: System::Void fileSystemWatcher1_Changed(System::Object^  sender, System::IO::FileSystemEventArgs^  e) 

  5. #5
    Registered User
    Join Date
    Aug 2008
    i think u need to set the EnableRaisingEvents property to true.

  6. #6
    Malum in se abachler's Avatar
    Join Date
    Apr 2007

    use the filter for detecting the last access time changing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  3. me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM