I think the easiest way is to use the hook to get notified (and eventually stop) the process. This is not possible in .NET, so you need DllImport to create many structures and several functions for P / Invoke.
Start your work with the NtSetFileInformation (undocumented) function. This is a function that is called by something else when a file needs to be deleted (using the FileDispositionInformation structure).
Now the problem is how to connect this function (good luck, it's not easy). A good choice would be to use Microsoft Detours . Take a look at this article for an example. His problem is that it is not free. An alternative solution (with a reasonable price and with the .NET interface) is Deviare , but I have never tried even their free version, I know how good it is. If anyone else knows a good interception tool ...
Adriano repetti
source share