Control access to files / directories in C #

I want to develop an application that registers files / directories available on a machine.

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

  • D: \ Opened
  • D: \ documents Open
  • D: \ documents \ secret.docx Open

I used FileSystemWatcher to achieve a different type of file system activity, but could not get events to access this.

+6
source share
3 answers

it sounds like you want to make a FileMon program, such as the inside of sys. on his website, Mark talks about how FileMon works so you can get inspired by reading the article.

also see here: How do you control file access and changes on a file server by username?

+3
source

I’m not sure that this kind of monitoring can be achieved using the filesystemwatcher, since it aims to monitor the changes that I consider. You can use file system auditing (by going to advanced security settings) that will log events in the event log, and you can pull it out of there.

+1
source

The most viable option is to use a file system filter driver. Such a driver gives you fine control over all requests sent to a specific file system. The only problem with this approach is the complexity of developing such a driver in kernel mode.

0
source

Source: https://habr.com/ru/post/895765/


All Articles