private static void OnChanged(object sender, FileSystemEventArgs e) { string pathInput = ConfigurationManager.AppSettings["InputFolder"]; string pathOutput = ConfigurationManager.AppSettings["OutputFolder"]; FileManager fileManager = new FileManager(); List<string> resultFolder = new List<string>(); fileManager.FindAllFolders(pathInput, resultFolder); var result = fileManager.FindAllFiles(resultFolder); Parser parser = new Parser(); InputFileManager inputFileManager = new InputFileManager(); foreach (var item in result) { var parseNameFile = parser.ParseNameFile(fileManager.GetNameFile(item)); var parseFile = parser.ParseFile(item); inputFileManager.AddInputFile(parseNameFile, parseFile); fileManager.MoveFile(item, pathOutput); Console.WriteLine(fileManager.GetNameFile(item) + " - обработан"); } }
private static void OnCreated(object sender, FileSystemEventArgs e) { DirectoryInfo source = new DirectoryInfo(@"D:\Watcher\New\"); DirectoryInfo destin = new DirectoryInfo(@"D:\Watcher\Old\"); foreach (var item in source.GetFiles()) { try { var parser = new Parser(); parser.ParserFiles(e.FullPath, e.Name); item.MoveTo(destin + item.Name); } catch (IOException exception) { Console.WriteLine(exception.Message); } } }