public static void CheckConfigRules(Rule rule, string path)
        {
            RulesManager rulesManager = new RulesManager();
            var          fileName     = Path.GetFileName(path);
            var          match        = Regex.Match(fileName, rule.FilePattern);

            if (match.Success)
            {
                rule.MatchesCount++;
                //path = AppendFileName(rule, path);
                var newFileName = Path.GetFileName(path);
                rulesManager.MoveToFolder(newFileName, path, rule.DestinationFolder);
            }
        }
Example #2
0
        private static void OnChanged(object source, FileSystemEventArgs e)
        {
            Console.WriteLine($"{messages.OnChangeMessage}: {e.FullPath} {e.ChangeType}");

            WatcherChangeTypes wct     = e.ChangeType;
            var          type          = wct.ToString();
            RulesManager rulesDetector = new RulesManager();
            ConfigReader configReader  = new ConfigReader();

            if (type == "Created")
            {
                if (!configFlag)
                {
                    rulesDetector.CheckRules(e.FullPath, flag);
                }
                else
                {
                    configReader.ConfigCheck(e.FullPath);
                }
            }
        }