C # FileSystemWatcher does not intercept Perforce revert

C # FileSystemWatcher does not intercept Perforce. It works great when changing the same file. This causes a problem because the check-in cancels the file, but the FileSystemWatcher is not notified.

How do you watch Perforce return?

Thank.

+1


source to share


4 answers


In addition to checking the NotifyFilters, make sure you bind handlers to all events that the FileSystemWatcher. FileSystemWatcher has events for Modified, Created, Deleted, and Renamed.

If you only bind to the Changed event and don't catch any events, it sounds like Perforce can delete and recreate the file. If so, add handlers to deleted and modified events.



The NotifyFilters documentation in msdn has a sample code showing how to handle all events.

+3


source


Have you configured the NotifyFilters correctly? From FileSystemWatcher Help ...

There are several types of changes that you can observe in a directory or file. For example, you can keep track of changes to attributes, the date and time of LastWrite, or the size of files or directories. This is done by setting the NotifyFilter property to one of the NotifyFilters values.



A Perforce revert can also revert to a previous LastWrite time, which if you are only looking for an earlier timestamp will not trigger an update.

+1


source


I tried a sample executable from CodeProject, it seems to work, there must be my code which is bad ...

0


source


I suspect the Perforce report is making a copy from a temporary file, so it doesn't actually write the file, but copies it to a new file and dumps the previous file. Since the file is not "being written to", you do not receive a notification. It won't help you :(

0


source







All Articles