Advertisement
Guest User

Untitled

a guest
Jun 8th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3. using System.Net;
  4. using XML_Base_Library.Ftp;
  5. using System.Collections;
  6.  
  7. namespace XML_Base
  8. {
  9.     class FtpUtil
  10.     {
  11.         private string username, password, FilePath, FileName, DownloadPath, serverip;
  12.         private int port;
  13.         private Queue q = new Queue(11);
  14.  
  15.         public FtpUtil(IPAddress serverIp, int Port, string username, string password)
  16.         {
  17.             this.username = username;
  18.             this.password = password;
  19.             this.serverip = serverIp.ToString();
  20.             this.port = Port;
  21.             //ftpClient.AutoChecksumValidation = HashingFunction.Crc32;
  22.         }
  23.  
  24.         private void GetFile()
  25.         {
  26.             FtpClient ftpClient = new FtpClient(serverip, port);
  27.             ftpClient.FileTransferType = TransferType.Binary;
  28.             ftpClient.DataTransferMode = TransferMode.Passive;
  29.             ftpClient.Open(username, password);
  30.             ftpClient.GetFile(FilePath + FileName, DownloadPath + this.FileName, FileAction.Create);
  31.             ftpClient.Close();
  32.         }
  33.  
  34.         public void Download(string FileName, string FilePath, string DownloadPath)
  35.         {
  36.             this.FileName = FileName;
  37.             this.FilePath = FilePath;
  38.             this.DownloadPath = DownloadPath;
  39.             q.Enqueue(FilePath + FileName);
  40.             Thread new1 = new Thread(new ThreadStart(GetFile));
  41.             new1.Start();
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement