Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ClientFTP
- {
- class Program
- {
- static FTP ftp;
- // sftp://username:password@domain:port
- static void Main(string[] args)
- {
- string port = "21", hostname = "", username = "", password = "";
- int intPort;
- /*
- Console.WriteLine("Podaj port:");
- port = Console.ReadLine();
- Console.WriteLine("Podaj domene:");
- domain = Console.ReadLine();
- Console.WriteLine("Podaj nazwe uzytkownika:");
- username = Console.ReadLine();
- Console.WriteLine("Podaj haslo:");
- password = Console.ReadLine();
- */
- ftp = new FTP(username, password, hostname, int.TryParse(port, out intPort) ? intPort : 21);
- mainLoop();
- }
- static void mainLoop()
- {
- Console.Clear();
- Console.WriteLine("Polaczono z " + ftp.hostname + "!");
- Console.WriteLine("Zawartosc katalogu " + ftp.currentDirectoryAbsolute + " :");
- Console.WriteLine(ftp.getDirectoryContents());
- bool flagExit = false;
- while(!flagExit)
- {
- Console.WriteLine("Dostepne opcje:");
- Console.WriteLine("1: wyswietl pelna sciezke biezacego katalogu");
- Console.WriteLine("2: wyswietl zawartosc biezacego katalogu");
- Console.WriteLine("3: wyswietl drzewo katalogow i plikow zaczynajac od biezacego katalogu");
- Console.WriteLine("4: wyswietl drzewo katalogow i plikow zaczynajac od roota");
- Console.WriteLine("5: zmien katalog");
- Console.WriteLine("0: wyjscie");
- int choice = -1;
- if (!int.TryParse(Console.ReadLine(), out choice))
- choice = -1;
- Console.Clear();
- switch (choice)
- {
- case 0:
- flagExit = true;
- break;
- case 1:
- Console.WriteLine("Biezacy katalog: " + ftp.currentDirectoryAbsolute);
- break;
- case 2:
- Console.WriteLine("Zawartosc katalogu: " + ftp.currentDirectoryAbsolute + " :\n");
- Console.WriteLine(ftp.getDirectoryContents());
- break;
- case 3:
- Console.WriteLine("Drzewo katalogow: " + ftp.currentDirectoryAbsolute + " :\n");
- Console.WriteLine(ftp.printDirectoryTree(ftp.currentDirectory));
- break;
- case 4:
- Console.WriteLine("Drzewo katalogow: \n");
- Console.WriteLine(ftp.printDirectoryTree("/"));
- break;
- case 5:
- Console.WriteLine("Podaj sciezke do nowego katalogu: ");
- string dir = Console.ReadLine();
- ftp.changeDirectory(dir);
- Console.WriteLine("Biezacy katalog: " + ftp.currentDirectoryAbsolute + "\n");
- break;
- case -1:
- Console.WriteLine("Niepoprawna opcja!");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement