【发布时间】:2013-05-13 09:41:26
【问题描述】:
我有问题。我在FileSystemWatcher 上编写了一个包装器,可以检测 root 文件夹及其所有子文件夹中的更改。没什么特别的:
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)。
一年前已经报告了不正确路径的问题(看起来已经解决了),但我的单声道来自去年 12 月(MonoDevelop 在参考部分说它是版本 4.0.0.0,我只能说关于分布)和错误仍然存在...... 看: https://bugzilla.xamarin.com/show_bug.cgi?id=5747
有什么想法吗?我真的很好奇是否有一种解决方法不需要编写自己的观察程序来重复轮询文件系统或为 root 下的每个文件夹启动单独的观察程序...
提前致谢!
【问题讨论】:
-
可能,这会有所帮助:[does-net-filesystemwatcher-work-with-mono-on-mac-os][1] [1]: stackoverflow.com/questions/5727652/…
-
看到这个话题,很遗憾我在那里找不到任何帮助...不过还是谢谢!
-
如果 5747 的错误修复没有解决您的情况,您只需在 bugzilla.xamarin.com 中创建一个新的不同错误
标签: c# macos mono filesystemwatcher