Beispiel #1
0
        public FSMonitor(string path, IWatcher watcher = null,
                         IDirectory directory          = null)
        {
            log = new List <string>();
            log.Add($"[{DateTime.Now.ToString("HH:mm")}]" +
                    " лог монитора директории " + path);

            if (watcher == null)
            {
                watcher = new FSWatcher();
            }
            if (directory == null)
            {
                directory = new FSDirectory();
            }

            this.watcher   = watcher;
            this.directory = directory;

            watcher.Path   = path;
            directory.Path = path;

            watcher.SubscribeError(Watcher_Error);
            watcher.SubscribeChanged(Watcher_Changed);
            watcher.SubscribeRenamed(Watcher_Renamed);
            watcher.SubscribeCreated(Watcher_Created);
            watcher.SubscribeDeleted(Watcher_Deleted);

            watcher.IncludeSubdirectories = true;
        }