![](/img/trans.png)
[英]C# FileSystemWatcher firing when i physically drop a file, however not when i use File.Move
[英]C# FileSystemWatcher not firing on Nas file system when making change from different computer
我有多台計算機(centos)安裝了 NAS 文件系統(Apsara File Storage)。 然后我使用 c# FileSystemWatcher 來監視文件創建/更新更改。 FileSystemWatcher 事件僅在運行程序本身的計算機進行更改時觸發。 附: 我試過 .netcore3.1 和 .net5 版本。
這是我的設置。
...
using var watcher = new FileSystemWatcher(dir);
watcher.NotifyFilter = NotifyFilters.Attributes
| NotifyFilters.CreationTime
| NotifyFilters.DirectoryName
| NotifyFilters.FileName;
watcher.Created += OnCreated;
watcher.Deleted += OnDeleted;
watcher.Filter = "*.log";
watcher.IncludeSubdirectories = true;
watcher.InternalBufferSize = 8192 * 8;
watcher.EnableRaisingEvents = true;
....
這個站點上有很多關於 FileSystemWatcher 可靠性的問題,結論總是一樣的:它不可靠。
Peter Meinl Tamed FileSystemWatcher的文章非常詳細地描述了這些限制,並提供了更可靠的解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.