Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在文件被删除之前获得一个事件?
我该怎么做?
根据我对这个问题的回答:如何防止使用 Windows 服务创建文件夹?
System.IO.FileSystemWatcher 或 .net 框架中的任何其他内容(据我所知)不支持在文件被删除之前接收事件,即在删除请求到达文件系统时,但在它被执行之前(我在这里假设您希望能够有选择地取消删除文件的请求)。
如果你想走这条路,你需要做的是编写一个File System Filter Driver,据我所知,你必须用非托管代码编写它。