Note that there are some explanatory texts on larger screens.

plurals
  1. POFileSystemWatcher under mono - watching subdirs
    text
    copied!<p>I have a problem. I have written a wrapper over <code>FileSystemWatcher</code> that detects changes in <em>root</em> folder and all of its subfolders. Nothing fancy:</p> <pre><code>FileSystemWatcher watcher = new FileSystemWatcher (); watcher.Path = this.Root; watcher.IncludeSubdirectories = true; watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.LastAccess | NotifyFilters.DirectoryName | NotifyFilters.FileName; watcher.Changed += new FileSystemEventHandler (watcher_Changed); watcher.Deleted += new FileSystemEventHandler (watcher_Deleted); watcher.Created += new FileSystemEventHandler (watcher_Created); watcher.Renamed += new RenamedEventHandler (watcher_Renamed); watcher.EnableRaisingEvents = true; </code></pre> <p>While in .NET, under Windows, it works like a charm. But when I ported the code to mono and ran the code under OSX, it works properly only in the root folder.</p> <p>Issues I have noticed by now:</p> <ul> <li><p>Events are not raised for operations within folders already existing under root at the time the watcher starts</p></li> <li><p>Paths I get via <code>EventArgs.FullPath</code> property are not correct (when I copy a file to path_to_root/some/more/subdirs/some.file, the path I get is just path_to_root/some.file).</p></li> </ul> <p>The issue with unproper paths has been already reported one year ago (and looks like it was solved) but my mono comes from December last year (MonoDevelop says in References section it is version 4.0.0.0, it is all I can say about the distribution) and the bugs are still there... See: <a href="https://bugzilla.xamarin.com/show_bug.cgi?id=5747">https://bugzilla.xamarin.com/show_bug.cgi?id=5747</a></p> <p>Any ideas? I am really curious if there is a workaround not requiring writing own watcher that polls the file system repeatedly or starting separate watcher for every folder under <em>root</em>...</p> <p>Thanks in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload