What you ask for can be done. Virus scanners, for example, do this all the time. You can easily monitor file activity using Process Monitor . You can also do this programmatically in C # using the FileSystemWatcher class . But an attempt to prevent a program from opening or trying to stop access to a program file cannot be made in C #. You will need to use C or C ++. You need to create a file system filter driver . This is a difficult task, but just what you need. To quote MSDN:
A file system filter driver intercepts requests targeted at a file system or another file system filter driver. By intercepting the request before it reaches its intended target, the filter driver can extend or replace functionality provided by the original target of the request. Examples of file system filter drivers include anti-virus filters, backup agents, and encryption products.
Icemanind
source share