Guest User

Untitled

a guest
Mar 13th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. using System.Net;
  7. using System.IO;
  8.  
  9. namespace SimpleFTPDownload_CLI
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. FTP_Download("ftp://muttismodemaus.mu.funpic.de/CIMG2824.JPG", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\CIMG2824.JPG", "muttismodemaus", "lenaundsusi");
  16. }
  17.  
  18. public static bool FTP_Download(string Remote, string Local, string UserName, string Password)
  19. {
  20. WebClient Request = new WebClient();
  21. Request.Credentials = new NetworkCredential(UserName, Password);
  22.  
  23. try
  24. {
  25. byte[] BinaryData = Request.DownloadData(Remote.ToString());
  26. FileStream File = new FileStream(Local, FileMode.Create, FileAccess.Write);
  27. File.Write(BinaryData, 0, BinaryData.Length);
  28. File.Close();
  29. }
  30. catch
  31. {
  32. return false;
  33. }
  34.  
  35. return true;
  36. }
  37. }
  38. }
Add Comment
Please, Sign In to add comment