public Watcher() { ConfigurationLoader configLoader = new ConfigurationLoader(); // Getting all possible options. AllOptions allOptions = configLoader.GetAllOptions(configurationPath); // Load all options. sourceDirectory = allOptions.watcherOptions.sourseDirectoryPath; targetDirectory = allOptions.watcherOptions.targetDirectoryPath; archiveDirectory = allOptions.archiveOptions.archiveDirectoryPath; loggerPath = allOptions.loggerOptions.logFilePath; enableArhivation = allOptions.archiveOptions.enableArchivation; enableEncryption = allOptions.encryptionOptions.enableEncryption; enableLogging = allOptions.loggerOptions.enableLogging; obj = new object(); logger = new Logger(loggerPath, enableLogging); // Entry about results of getting options. logger.AddEntry(configLoader.logMessage); watcher = new FileSystemWatcher(sourceDirectory); // Only watch text files. watcher.Filter = "*.txt"; // Add event handlers. watcher.Created += WatcherCreated; }