Esempio n. 1
0
        static void OnChanged(object source, FileSystemEventArgs e)
        {
            Console.WriteLine($"File: {e.FullPath} {e.ChangeType}");

            BackupCreation.CreateBackupDirectories(BackupCreation.GetAllFilesForBackups(Program.pathToOriginal), Program.pathToAllBackups);

            BackupCreation.CreateBackup(e.FullPath);
        }
Esempio n. 2
0
        public static void DoCase1()
        {
            FileSystemWatcher watcher = new FileSystemWatcher();

            watcher.Path     = Program.pathToOriginal;
            watcher.Filter   = "*.txt";
            watcher.Changed += OnChanged;
            watcher.Created += OnChanged;
            watcher.Deleted += OnChanged;
            watcher.Renamed += OnRenamed;

            string[] files = BackupCreation.GetAllFilesForBackups(Program.pathToOriginal);
            BackupCreation.CreateBackupDirectories(files, Program.pathToAllBackups);
            BackupCreation.CreateBackup(files, Program.pathToAllBackups);

            watcher.EnableRaisingEvents = true;

            Console.ReadKey();
        }