簡體   English   中英

從不同的計算機進行更改時,C# FileSystemWatcher 不會在 Nas 文件系統上觸發

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM