[Mono-list] FileSystemWatcher difference between mono and .Net

edward.harvey.mono edward.harvey.mono at clevertrove.com
Fri Nov 9 03:03:50 UTC 2012


I don't know if anyone will care, but I observed a difference in behavior between mono 2.10.9 on windows, and .Net 4.0.

When you rename a file, in mono, FileSystemWatcher triggers a WatcherChangeTypes.Created and WatcherChangeTypes.Deleted event.
In .Net, it triggers a WatcherChangeTypes.Renamed event.

While it is conceivable in some cases you might prefer to have the Created & Deleted events, there's one really solid situation *not* to want that.  If you are using FileSystemWatcher to keep some directory mirrored, following changes of some source directory, then Created & Deleted events mean you have to copy the file from source to destination and delete the old one.  Whereas, a Renamed event can be replicated for much lower cost; all you need to do is perform the Rename operation on the destination.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20121109/4f605d2c/attachment-0001.html>


More information about the Mono-list mailing list