Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using BytesRoad.Net.Ftp;
  7. using BytesRoad.Net.Sockets;
  8. using BytesRoad.Diag;
  9. using System.Text;
  10. using System.IO;
  11. using System.Linq;
  12.  
  13. namespace PasvordBlok
  14. {
  15.     class Program
  16.     {
  17.         static void Main(string[] args)
  18.         {
  19.             bool pascont=true;
  20.             string defpas = "Slavko";
  21.             while (pascont)
  22.             {
  23.                 Console.Write("passvord: ");
  24.                 string passvord = Console.ReadLine();
  25.                 if (passvord == defpas)
  26.                 {
  27.                     Console.Write("Pasvors for site: ");
  28.                     string pasvordforsite=Console.ReadLine();
  29.                     pasvordforsite += "\n";
  30.                     //Сам клиент ФТП
  31.                     FtpClient client = new FtpClient();
  32.                     //Задаём параметры клиента.
  33.                     client.PassiveMode = true; //Включаем пассивный режим.
  34.                     int TimeoutFTP = 30000; //Таймаут.
  35.                     string FTP_SERVER = "185.28.20.34";
  36.                     int FTP_PORT = 21;
  37.                     string FTP_USER = "u484123398";
  38.                     string FTP_PASSWORD = "5556874";
  39.                     string nameofdownfile = "_.d";
  40.                     client.Connect(TimeoutFTP, FTP_SERVER, FTP_PORT);
  41.                     client.Login(TimeoutFTP, FTP_USER, FTP_PASSWORD);
  42.                     //.... Здесь выполняем то что хотим с сервером ...
  43.                     Console.WriteLine(client.GetDirectoryList(TimeoutFTP));
  44.                     // client.CreateDirectory(TimeoutFTP, "dsdsdsd");
  45.                     string name = nameofdownfile;
  46.                     FileStream file1 = new FileStream(name, FileMode.Create); //создаем файловый поток
  47.                     StreamWriter writer = new StreamWriter(file1); //создаем «потоковый писатель» и связываем его с файловым потоком
  48.                     writer.Write(pasvordforsite); //записываем в файл
  49.                     writer.Close(); //закрываем поток. Не закрыв поток, в файл ничего не запишется
  50.                     client.PutFile(TimeoutFTP, nameofdownfile, nameofdownfile);
  51.                     //Отключаемся от ФТП сервера
  52.                     client.Disconnect(TimeoutFTP);
  53.                     File.Delete(nameofdownfile);
  54.                     pascont = false;
  55.                 }
  56.                 else
  57.                 {
  58.                     Console.WriteLine("error");
  59.                 }
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement