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;
- using BytesRoad.Net.Ftp;
- using BytesRoad.Net.Sockets;
- using BytesRoad.Diag;
- using System.Text;
- using System.IO;
- using System.Linq;
- namespace PasvordBlok
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool pascont=true;
- string defpas = "Slavko";
- while (pascont)
- {
- Console.Write("passvord: ");
- string passvord = Console.ReadLine();
- if (passvord == defpas)
- {
- Console.Write("Pasvors for site: ");
- string pasvordforsite=Console.ReadLine();
- pasvordforsite += "\n";
- //Сам клиент ФТП
- FtpClient client = new FtpClient();
- //Задаём параметры клиента.
- client.PassiveMode = true; //Включаем пассивный режим.
- int TimeoutFTP = 30000; //Таймаут.
- string FTP_SERVER = "185.28.20.34";
- int FTP_PORT = 21;
- string FTP_USER = "u484123398";
- string FTP_PASSWORD = "5556874";
- string nameofdownfile = "_.d";
- client.Connect(TimeoutFTP, FTP_SERVER, FTP_PORT);
- client.Login(TimeoutFTP, FTP_USER, FTP_PASSWORD);
- //.... Здесь выполняем то что хотим с сервером ...
- Console.WriteLine(client.GetDirectoryList(TimeoutFTP));
- // client.CreateDirectory(TimeoutFTP, "dsdsdsd");
- string name = nameofdownfile;
- FileStream file1 = new FileStream(name, FileMode.Create); //создаем файловый поток
- StreamWriter writer = new StreamWriter(file1); //создаем «потоковый писатель» и связываем его с файловым потоком
- writer.Write(pasvordforsite); //записываем в файл
- writer.Close(); //закрываем поток. Не закрыв поток, в файл ничего не запишется
- client.PutFile(TimeoutFTP, nameofdownfile, nameofdownfile);
- //Отключаемся от ФТП сервера
- client.Disconnect(TimeoutFTP);
- File.Delete(nameofdownfile);
- pascont = false;
- }
- else
- {
- Console.WriteLine("error");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement