How can i get user who deleted file?

2019-04-27 19:45发布

问题:

I need to know which user deleted file in filesystem from c# code. Only one idea is to use audit, but it seem to be very slow...

回答1:

You can use the FileSystemWatcher.Deleted event to capture deletes happening on the filesystem.

Depending on the application, you may at that point also be able to find out what user caused this event to occur (it is not part of FileSystemEventArgs).



回答2:

I don't know if this can be retrieved from the filsystem, but one possible way is to use av FileSystemWatcher object to trigger an event on Deleted. The downside is that you need to have the watcher application running all the time. One upside is that you can monitor just a spesific folder if that's feasible.