Esempio n. 1
0
        private static void OnRenamed(object source, RenamedEventArgs e)
        {
            FileEditingClass fileEditingClass = new FileEditingClass();

            FileEditingClass.CopyAllFilesToBackups();
            fileEditingClass.SaveNewPathForRenamedFiles(e.OldFullPath, e.FullPath);
            Console.WriteLine($"File {e.OldFullPath} renamed to {e.FullPath}");
        }
Esempio n. 2
0
        public static void ConsoleInterface()
        {
            Console.WriteLine("Hello, this is a backup system for text files.");

            bool isInput = true;

            while (isInput)
            {
                Console.WriteLine("What mode of operation to include?"
                                  + Environment.NewLine + "\t 1: watcher mode"
                                  + Environment.NewLine + "\t 2: rollback changes"
                                  + Environment.NewLine + "\t 3: exit from the program");
                if (int.TryParse(Console.ReadLine(), out int result))
                {
                    switch (result)
                    {
                    case 1:
                    {
                        Watcher.Run();
                        break;
                    }

                    case 2:
                    {
                        string           dateTimeForBackup = ChooseDateAndTimeForBackup();
                        FileEditingClass fileEditingClass  = new FileEditingClass();
                        fileEditingClass.Backup(dateTimeForBackup);
                        break;
                    }

                    case 3:
                    {
                        isInput = false;
                        break;
                    }

                    default:
                    {
                        Console.WriteLine("Unknown command!");
                        break;
                    }
                    }
                }
            }
        }
Esempio n. 3
0
 static void Main(string[] args)
 {
     FileEditingClass.CopyAllFilesToBackups();
     WorkWithConsoleClass.ConsoleInterface();
 }
Esempio n. 4
0
 private static void OnChanged(object source, FileSystemEventArgs e)
 {
     FileEditingClass.CopyAllFilesToBackups();
     Console.WriteLine($"File {e.FullPath} {e.ChangeType}");
 }