it does not generate an event even when LastAccessed is added.
Because NotifyFilters.LastAccessed indicates that you want to find this property, not the event you want to subscribe to. Available events: Changed , Created or Deleted , none of which do what you want.
You should take a look at the ReadDirectoryChangesW documented Win32 function. It can be passed the FILE_NOTIFY_CHANGE_LAST_ACCESS flag, which seems to deliver what you want:
Any change in the last access time of files in the scanned directory or subtree results in the return of the change notification operation.
Edit: ignore this, FileSystemWatcher executes the NotifyFilters.LastWrite internal pass as int 32, which is the same as FILE_NOTIFY_CHANGE_LAST_ACCESS , with ReadDirectoryChangesW . This function still does not notify about access to the file, I tried.
Perhaps this is caused by this :
Last access time has free detail, which ensures that the time will be accurate within one hour. In Windows Vista, we turned off updates for recent access times to improve NTFS performance. If you use an application that relies on this value, you can enable it using the following command:
fsutil behavior set disablelastaccess 0
For this change to take effect, you must restart the computer.
If you do this on the command line, LastAccess may be written and the event will fire. I will not try to connect to my SSD and not have a virtual machine, but in Windows 7 disablelastaccess seems to be included out of the box.
If it still doesn’t work when you turn off this behavior, wait for Raymond Chen (or himself) to appear, as a rule, there is a quite logical explanation of why the documentation does not seem to correctly describe the behavior you encounter ;; -)
You can simply scan the directory in a loop and look at the LastAccessed property of the files. What are you trying to do when a user opens a specific file?