public FolderWatcher(string directoryPath, WatermarkImage watermarkImage, ILog log) { if (string.IsNullOrWhiteSpace(directoryPath)) { throw new ArgumentNullException(nameof(directoryPath)); } if (!Directory.Exists(directoryPath)) { throw new DirectoryNotFoundException($"{directoryPath} is not a valid directory"); } string completedFolder = Path.Combine(directoryPath, "completed"); string failedFolder = Path.Combine(directoryPath, "failed"); _completeDirectory = Directory.CreateDirectory(completedFolder); _failedDirectory = Directory.CreateDirectory(failedFolder); _watcher = new FileSystemWatcher(directoryPath) { NotifyFilter = NotifyFilters.FileName | NotifyFilters.CreationTime | NotifyFilters.LastWrite, Filter = "**" }; _watcher.Changed += OnChanged; _watermarkImage = watermarkImage; _log = log; }
public Form1(ILog log) { _log = log ?? throw new ArgumentNullException(nameof(log)); InitializeComponent(); _watermarkImage = new WatermarkImage(); pictureBox1.Image = _watermarkImage.GetImage(); try { _settings = Settings.Load(); } catch (Exception e) { _settings = new Settings(); log.Exception("Settings failed to load", e); } FormClosed += OnClosed; DragEnter += (sender, args) => args.Effect = DragDropEffects.Copy; DragDrop += HandleDrop; label1.Text = _settings.SaveDirectory ?? "(No directory)"; }