FileSystemWatcher - Changed event for ReadOnly attribute

It seems that FileSystemMonitor does not fire the Modified event (and no other events) when the ReadOnly attribute of a file changes in a controlled directory.

This is my test code:

    using System;
    using System.IO;

    namespace FSM
    {
        class Program
        {
            static FileSystemWatcher FolderMonitor;


            static void Main(string[] args)
            {
            FolderMonitor = new FileSystemWatcher("C:\\MyImages");
            FolderMonitor.IncludeSubdirectories = false;
            FolderMonitor.Changed += FolderMonitor_Changed; ;
            FolderMonitor.EnableRaisingEvents = true;

            Console.WriteLine("Hit any key to terminate .....");
            Console.ReadKey(true);
        }


        private static void FolderMonitor_Changed(object sender, FileSystemEventArgs e)
        {
            Console.WriteLine("****  \"" + e.Name + "\" changed.");
        }
    }

With this code, I get a lot of Modified events, for example. if the change timestamp has changed, but not if I change any standard attributes such as ReadOnly or Hidden.

Am I missing something or hit a "function"?

+4
source share
1 answer

NotifyFilter, , . . FileSystemWatcher.NotifyFilter

.

FolderMonitor.NotifyFilter = NotifyFilters.Attributes;
+5

Source: https://habr.com/ru/post/1664549/


All Articles