C# FileSystemWatcher 不会捕获 Perforce 还原。修改同一个文件时它工作正常。这会导致问题,因为还原会更改文件,但 FileSystemWatcher 不会收到通知。
你如何观察 Perforce 恢复?
谢谢你。
C# FileSystemWatcher 不会捕获 Perforce 还原。修改同一个文件时它工作正常。这会导致问题,因为还原会更改文件,但 FileSystemWatcher 不会收到通知。
你如何观察 Perforce 恢复?
谢谢你。
In addition to checking the NotifyFilters, make sure you're attaching handlers to all of the events that the FileSystemWatcher has. FileSystemWatcher has events for Changed, Created, Deleted and Renamed.
If you're only attaching to the Changed event and not catching any events, then it sounds like Perforce might be deleting and recreating the file. If this is the case, add handlers to the Deleted and Changed events.
The NotifyFilters documentation on msdn has example code showing handling for all of the events.
您是否正确设置了 NotifyFilters?从 FileSystemWatcher 帮助...
您可以在目录或文件中观察多种类型的更改。例如,您可以观察属性、LastWrite 日期和时间或文件或目录大小的变化。这是通过将 NotifyFilter 属性设置为 NotifyFilters 值之一来完成的。
Perforce 恢复也可能恢复到以前的 LastWrite 时间,如果您只是在寻找更新的时间戳,则不会触发更新。
我怀疑 Perforce 报告会从临时文件中复制一份,所以它实际上并没有写入文件,而是复制到一个新文件中并删除了前一个文件。因此,由于文件没有被“写入”,因此您不会收到通知。虽然它对你没有帮助:(
我尝试了来自 CodeProject 的示例可执行文件,它似乎可以工作,一定是我的代码很糟糕......