Esempio n. 1
0
        static void Main(string[] args)
        {
            WorkingDirectory = DirectoryHelper.GetCurrentDirectory();
            WriteToConsole("Welcome to Barry's Command Line Console", true, false);
            WriteToConsole(string.Empty, true, false);
            WriteToConsole(WorkingDirectory, false, true);

            CommandLineDetail cld = new CommandLineDetail(Console.ReadLine());

            while (!string.IsNullOrEmpty(cld.Command) && (cld.Command != "QUIT"))
            {
                DetermineSwitch(cld);

                WriteToConsole(WorkingDirectory, false, true);
                cld = new CommandLineDetail(Console.ReadLine());
            }
        }
Esempio n. 2
0
 private static void DetermineSwitch(CommandLineDetail cld)
 {
     try
     {
         switch (cld.Command)
         {
             case "":
             case "CD":
             case "CHDIR":
                 if (cld.HasArguments)
                     ChangeDirectoryCommand(cld.Arguments[0]);
                 break;
             case "DEL":
                 DeleteCommand(cld.Arguments);
                 break;
             case "DIR":
                 DirectoryCommand(cld.Arguments);
                 break;
             case "RD":
             case "RMDIR":
                 RemoveDirectoryCommand(cld.Arguments);
                 break;
             case "REN":
             case "RENAME":
                 RenameCommand(cld.Arguments);
                 break;
             case "HELP":
                 HelpCommand();
                 break;
             default:
                 WriteToConsole("Unknown Command", true, false);
                 HelpCommand();
                 break;
         }
     }
     catch (Exception ex)
     {
         WriteToConsole(ex.Message, true, false);
     }
 }