コード例 #1
0
        private void OnHandlerDT(object sender, FileSystemEventArgs e)
        {
            var date   = DateTime.Now;
            var newDir = _logDirectory + PrintDT(date);

            SystemRestorerHandler.DirectoryCopy(_sourceDirectory, newDir, true);
        }
コード例 #2
0
        public static void BackupSystem()
        {
            Console.WriteLine("Input path to directory with files");
            var pathF = CheckPath();

            Console.WriteLine("Input path to directory in which you whant to save logs");
            var pathL = CheckPath();

            while (true)
            {
                Console.WriteLine("What you whant to do?\n" +
                                  "1. Observe\n" +
                                  "2. Restore\n" +
                                  "0. Exit");
                if (!int.TryParse(Console.ReadLine(), out int mode))
                {
                    Console.WriteLine("Error. Please, try again.");
                    continue;
                }
                if (mode < 0 || mode > 2)
                {
                    Console.WriteLine("Error. Please, try again.");
                    continue;
                }
                switch (mode)
                {
                case 1:
                    Console.Clear();
                    Console.WriteLine("Observation enabled...");
                    var observer = new SystemLoggerHandler(pathF, pathL);
                    observer.Run();
                    break;

                case 2:
                    Console.WriteLine("Restorer enabled...");
                    var restorer = new SystemRestorerHandler(pathF, pathL);
                    restorer.Run();
                    break;

                case 0:
                    return;

                default:
                    Console.WriteLine("Error. Please, try again.");
                    break;
                }
                Console.ReadLine();
            }
        }