Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

monitor file/directory access in C#

I want to develop the application which logs the files / directories accessed on the machine.

e.g. I go to D:\ and into a folder documents and open a word file. I want my application to create a log in the following format:

  1. D:\ Opened
  2. D:\documents Opened
  3. D:\documents\secret.docx Opened

I've used FileSystemWatcher to achieve the other type of file system activity but unable to get events for accessing this.

like image 842
Balwant Singh Avatar asked Aug 24 '11 15:08

Balwant Singh


2 Answers

sounds like you wanna do a FileMon program like sys internals. in their website Mark tells about the way FileMon works so you can get some inspiration by reading the article.

also see here: How do you monitor file access and changes on a file server by user name?

like image 199
Davide Piras Avatar answered Oct 01 '22 22:10

Davide Piras


Not sure this sort of monitoring can be achieved with filesystemwatcher as it is aimed at monitoring changes I believe. You could use filesystem Auditing (by going into advanced security settings) which will log events in eventlog and you can pull it from there.

like image 40
Maverik Avatar answered Oct 01 '22 23:10

Maverik