我遇到問題。我用FileSystemWatcher
寫了一個包裝,它檢測根文件夾及其所有子文件夾中的更改。沒有什麼奇特的:FileSystemWatcher在單播觀看子目錄下
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;
在.NET中,在Windows下,它就像一個魅力。但是,當我將代碼移植到mono並在OSX下運行代碼時,它只能在根文件夾中正常工作。
問題我已經通過,現在發現:
事件不會在觀察者開始
路徑我通過
EventArgs.FullPath
屬性獲取時間下根已經存在的文件夾內,提高了操作不正確(當我將一個文件複製到path_to_root/some/more/subdirs/some.file時,我得到的路徑就是path_to_root/some.file)。
與unproper路徑問題已經被報道一年前(和看起來好像是解決了),但我的單來自於去年十二月(MonoDevelop的說,在參考部分是4.0.0.0版本,它是所有我可以說的分佈)和錯誤仍然存在... 請參閱: https://bugzilla.xamarin.com/show_bug.cgi?id=5747
任何想法?我真的很好奇,如果有一個解決方法不需要寫自己的觀察者輪詢文件系統重複或啓動每個文件夾下的每個文件夾根 ...
在此先感謝!
可能,這可以幫助:不淨FileSystemWatcher的工作與 - 單上-MAC-OS] [1] [1]:http://stackoverflow.com/問題/ 5727652/do-net-filesystemwatcher-work-with-mono-on-mac-os – 2013-05-13 10:55:08
看到這個話題,不幸的是我找不到任何幫助...但謝謝! – wojtuch 2013-05-13 10:58:28
如果5747修正錯誤的未解決您的情況,您應該簡單地建立在http://bugzilla.xamarin.com – knocte 2013-08-09 12:22:21