/// <summary> /// Method that will trigger on new or changed file /// </summary> /// <param name="obj"></param> /// <param name="e"></param> private void NewOrChangedFile(object obj, FileSystemEventArgs e) { Logger.Info("New file triggered"); // Start a new thread of the file to lower the wait time of the watcher Thread t = new Thread(() => FileDiffEvaluator.NewOrChangedFile(e, source, destination)); t.Start(); }
/// <summary> /// Method that make a first copy of the source folder /// </summary> public void InitNew() { Logger.Info("Init first copy of a new backup "); // Get the list of files in a directory string[] files = Directory.GetFiles(source); // For each files in the directory foreach (var item in files) { // Copy the file using a thread FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.All, source, Path.GetFileName(item)); Thread t = new Thread(() => FileDiffEvaluator.NewOrChangedFile(e, source, destination)); t.Start(); } // Call run when the init is done Run(); }