Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // Welcome the user.
            Console.WriteLine("Welcome to Simple FTP Client.");
            Console.WriteLine("Type help for a list of commands.");

            UserInteraction.GetStartVariables();

            ftp = new FTP(username, password, ftpServer);

            while (true)
            {
                CMD();
            }
        }
Exemplo n.º 2
0
        static void CMD()
        {
            // Declare variable
            string cmd;

            // Get it.
            Console.Write(username + "@" + ftpServer + " $");
            cmd = Console.ReadLine();

            // Log the command if logging is enabled
            Check(true, cmd);

            switch (cmd.ToLower())
            {
            // FTP commands
            case "upload file":
                UserInteraction.GetVariablesForUploadFile(false);
                break;

            case "upload file -silent":
                UserInteraction.GetVariablesForUploadFile(true);
                break;

            case "download file":
                UserInteraction.GetVariablesForDownloadFile(false);
                break;

            case "download file -silent":
                UserInteraction.GetVariablesForDownloadFile(true);
                break;

            case "download all files in dir":
                UserInteraction.DownloadAllFilesInDir(false);
                break;

            case "download all files in dir -silent":
                UserInteraction.DownloadAllFilesInDir(true);
                break;

            case "get files in dir":
                UserInteraction.PrintAllFilesInDir(false);
                break;

            case "get files in dir -silent":
                UserInteraction.PrintAllFilesInDir(true);
                break;

            case "upload folder":
                UserInteraction.UploadLocalFolder(false);
                break;

            case "upload folder -silent":
                UserInteraction.UploadLocalFolder(true);
                break;

            // Credentials commands
            case "save credentials":
                CredentialsHandling.SaveCredentials();
                break;

            case "load credentials":
                CredentialsHandling.LoadCredentials();
                break;

            // Logging commands
            case "enable logging":
                Logging = true;
                Console.WriteLine("Logging is now enabled.");
                break;

            case "disable logging":
                Logging = false;
                Console.WriteLine("Logging is now disabled");
                break;

            case "write log to file":
                Log.WriteLogToFile();
                break;

            // Main Commands
            case "help":
                UserInteraction.Help();
                break;

            case "exit":
                UserInteraction.Exit();
                break;

            case "quit":
                Log.WriteLogToFile();
                System.Threading.Thread.Sleep(500);
                Environment.Exit(0);
                break;

            default:
                Console.WriteLine("Woops, command not found.");
                break;
            }
        }