Beispiel #1
0
        static void Unlocking(Password pass)
        {
            try
            {
                // clear start menu
                Console.Clear();
                DriveHolder d_holder = new DriveHolder();
                d_holder.ShowAvailableDrives(false);

                // enter the partition letter
                string partition_letter = DriveLetterInput();

                Drive current_drive = new Drive(partition_letter);

                if (current_drive.Folders.Length == 0 && current_drive.Files.Length == 0)
                {
                    Console.WriteLine("Drive " + current_drive.DriveObj.Name + " is empty");
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
                    Unlocking(pass);
                }
                else
                {
                    PasswordVerifyAndUnlock(current_drive, pass);
                }
            }
            catch
            {
                Console.WriteLine("Something went wrong");
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
                Unlocking(pass);
            }
        }
Beispiel #2
0
        static void Locking()
        {
            try
            {
                // clear start menu
                Console.Clear();
                DriveHolder d_holder = new DriveHolder();
                d_holder.ShowAvailableDrives(true);

                // enter the partition letter
                string partition_letter = DriveLetterInput();

                // get all files from partition
                Drive current_drive = new Drive(partition_letter);

                if (current_drive.Folders.Length == 0 && current_drive.Files.Length == 0)
                {
                    Console.WriteLine("Drive " + current_drive.DriveObj.Name + " is empty");
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
                    Locking();
                }
                else
                {
                    Console.WriteLine();

                    if (current_drive.Lock())
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Drive successfully locked!");
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Error locking the drive!");
                        Console.ResetColor();
                    }

                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
                    ProgramStart();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
                Locking();
            }
        }