0

I got multiple computer (centos) mounting a NAS file system (Apsara File Storage). Then I'm using the c# FileSystemWatcher to monitor file create/update changes. The FileSystemWatcher event only fire when changes maked by the computer which runing the program itself. ps. I've tried .netcore3.1 and .net5 version.

This is my setup.

           ... 
           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; 
            ....
  • 2
    The [documentation](https://learn.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher?view=net-5.0) does say "Remote computers must have one of the required platforms installed for the component to function properly." but fails to list or link to the required platforms. – Damien_The_Unbeliever Nov 10 '21 at 07:53

1 Answers1

0

There is plenty of questions on this site that discuss FileSystemWatcher reliability and the conclusion is always the same: it is not reliable.

The article from Peter Meinl Tamed FileSystemWatcher describes the limitations in great detail and also provides a more reliable solution.

geldek
  • 503
  • 2
  • 10