AcManager.Tools.Managers.InnerHelpers.DirectoryWatcher.DirectoryWatcher C# (CSharp) Method

DirectoryWatcher() public method

public DirectoryWatcher ( [ directory ) : System
directory [
return System
        public DirectoryWatcher([NotNull] string directory) {
            if (directory == null) throw new ArgumentNullException(nameof(directory));

            TargetDirectory = directory;

            var parentDirectory = Path.GetDirectoryName(TargetDirectory);
            if (parentDirectory == null || !Directory.Exists(parentDirectory)) {
                _failed = true;
                Logging.Error("FAILED DUE TO PARENT DIRECTORY MISSING: " + TargetDirectory);
                return;
            }

            _helperWatcher = new FileSystemWatcher {
                Path = parentDirectory,
                NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName,
                Filter = Path.GetFileName(TargetDirectory),
                EnableRaisingEvents = true,
                IncludeSubdirectories = false
            };

            _helperWatcher.Created += HelperWatcher_Something;
            _helperWatcher.Renamed += HelperWatcher_Something;
            _helperWatcher.Deleted += HelperWatcher_Something;
            UpdateInnerWatcher();
        }