0

Is there an easy-to-implement method to detect whenever a user opens a file?(double click, right click, etc.)

I've read this but I think it only polls the file's lastaccess time. The main goal that I'm trying to achieve is whenever a user opens a file, the code picks up file name, location, size and all that good stuff.

I don't think I can ask this in any other way. I'm at a loss as to where to start.

Community
  • 1
  • 1
Aloha
  • 864
  • 18
  • 40

1 Answers1

-1

Actually, the FileSystemWatcher from your linked question is the correct way to go. It does NOT poll anything, it listens to the OS events for file access. If there is no OS event, you cannot react to it.

Jan Dörrenhaus
  • 6,581
  • 2
  • 34
  • 45
  • 1
    OpenFile() is not propagated through a FileSystemWatcher. OP is looking for an event when a user opens a file, not writes to it, and the latter still is hard to detect without polling. – CodeCaster Nov 03 '15 at 13:22
  • Like I said: If there is no OS event, you cannot react to it. What exactly would you poll on? – Jan Dörrenhaus Nov 03 '15 at 13:23
  • 1
    I agree. I believe we are talking past one another. My point was: The FileSystemWatcher is the best the .NET API offers for listening to file access. For doing something like the OP suggests, the .NET API cannot help. – Jan Dörrenhaus Nov 03 '15 at 13:33