简体   繁体   English

从我的操作系统的任何文件夹中检测文件删除,并防止c#或win32 api删除

[英]File deletion detect from any folder of my operating system and prevent the deletion by c# or win32 api

i know we can monitor a particular folder with FileSystemWatcher. 我知道我们可以用FileSystemWatcher监视一个特定的文件夹。 with the help of FileSystemWatcher we can save the log which file was deleted. 在FileSystemWatcher的帮助下,我们可以保存删除文件的日志。 suppose i have windows service which will run all the time and if any user try to delete any file from my OS with specific extension then control then my windows service will show a messge box to user and prevent the user to delete that file. 假设我有Windows服务,它会一直运行,如果有任何用户尝试从我的操作系统中删除任何具有特定扩展名的文件然后控制,那么我的Windows服务将向用户显示一个消息框并阻止用户删除该文件。 i just want to know can i do this with FileSystemWatcher class. 我只想知道我可以用FileSystemWatcher类做到这一点。 if it is possible with FileSystemWatcher then please discuss here how or if not possible with FileSystemWatcher then how could i make it possible with my win service or normal win apps. 如果有可能使用FileSystemWatcher,那么请在这里讨论如何或如果不可能使用FileSystemWatcher,那么我怎样才能使用我的win服务或普通的win应用程序。 would it be possible by win32 api?? win32 api有可能吗? . thanks 谢谢

使用适当的Windows安全措施 - 文件权限以及访问组。

The only way is to have a filesystem filter driver which will track deletion and movement request (movement to recycle bin here) and will cancel such requests. 唯一的方法是有一个文件系统过滤器驱动程序,它将跟踪删除和移动请求(此处移动到回收站)并将取消此类请求。 You can write your own filter driver or use our CallbackFilter product. 您可以编写自己的过滤器驱动程序或使用我们的CallbackFilter产品。 With CallbackFilter the task is trivial - less than a dozen of lines of code in user-mode (possibly in C#). 使用CallbackFilter,任务很简单 - 在用户模式下可能少于十几行代码(可能在C#中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM