private void CatchingChanges(object sender, FileSystemEventArgs eventArgs) { var date = DateTime.Now.ToString("dd.MM.yyyy_HH.mm.ss"); var newDir = _logDirectory + date; File.AppendAllText(_logDirectory + "Log.txt", "Backup was created successfully. You can restore it by this time :" + date + Environment.NewLine); File.AppendAllText(_logDirectory + "LogforList.txt", date + Environment.NewLine); Restorer.DirectoryCopy(_sourceDirectory, newDir, true); }
public static void ChooseBackupOperations() { Console.WriteLine("Please, input here the path to directory which you want to backup"); var pathFileDir = CheckPath(); Console.WriteLine("Please, input here the path to directory for logs"); var pathLogDir = CheckPath(); while (true) { Console.WriteLine("What do you want to do?" + "\n1. Directory monitoring" + "\n2. Directory restoration" + "\n0. Exit"); if (int.TryParse(Console.ReadLine(), out int selection)) { switch (selection) { case 1: Console.Clear(); Console.WriteLine("Directory monitoring enabled."); var logger = new Logger(pathFileDir, pathLogDir); logger.DirectoryMonitoring(); break; case 2: Console.WriteLine("Directory restoration enabled."); var restorer = new Restorer(pathFileDir, pathLogDir); restorer.DirectoryRestoration(); break; case 0: return; default: Console.WriteLine("You selected non-existent case! Please select other."); break; } } Console.ReadLine(); } }