如何找出谁修改了 C# 或 Powershell 中的共享目录和文件?

How to find out who modified a shared directories and files in C# or Powershell?

我正在设计一项 Windows 服务,其主要目的是监控网络共享内容。我已经了解了 FileSystemWatcher class 的优点和缺点,并且我可能会通过一些自定义增强来使用它。困扰我的一件事是我仍然不知道如何获取有关谁确切修改了共享文件的信息。我认为它可以以某种方式从 Windows 中的权限机制中提取出来,但是如何提取呢?您是否知道如何至少让访问和修改共享内容的人登录? 我可以使用 C# 或 PowerShell。

最好的方法是启用advanced file auditing on the servers you need this information on. If that isn't an option (it can get quite inefficient on servers with high disk IO), you can try using FileSystemWatcher to get the same results. Here是如何做到这一点的一个例子!