FileSystemWatcher ChangedEvent不会为dll文件触发

时间:2016-10-29 22:14:53

标签: c# dll filter filesystemwatcher

我有一个监视目录以进行DLL版本更改的服务。有趣的是我在另一台PC上使用了这个确切的代码,它运行得很好。我删除了" .dll"过滤,然后尝试运行它来搜索所有文件(。*),它会触发......但这不是我想要的。我只想要Dll文件。不知道为什么这不起作用..

FileSystemWatcher _watcher = new FileSystemWatcher();
        string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
        /// <summary>
        /// Starts the service
        /// </summary>
        /// <returns></returns>
        public bool Start()
        {

            var path = @"C:\Test";
            _watcher.NotifyFilter = NotifyFilters.Attributes;

            _watcher.Path = path;
            _watcher.Filter = "*.dll";
            _watcher.EnableRaisingEvents = true;
            _watcher.IncludeSubdirectories = true;

            _watcher.Changed += _watcher_Changed;

            return true;
        }

0 个答案:

没有答案