Guest User

Untitled

a guest
May 1st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 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 ftp_test
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. FtpWebRequest ftp;
  16.  
  17. string f_address;
  18. string f_user;
  19. string f_pass;
  20.  
  21. Console.WriteLine("Please enter an ftp address:");
  22. f_address = Console.ReadLine();
  23.  
  24. Console.WriteLine("\nuser:");
  25. f_user = Console.ReadLine();
  26.  
  27. Console.WriteLine("\npass:");
  28. f_pass = Console.ReadLine();
  29.  
  30. ftp = (FtpWebRequest)FtpWebRequest.Create(f_address);
  31. ftp.Credentials = new NetworkCredential(f_user, f_pass);
  32.  
  33. Console.Clear();
  34.  
  35. ftp.Method = WebRequestMethods.Ftp.ListDirectory;
  36. WebResponse response = ftp.GetResponse();
  37. StreamReader reader = new StreamReader(response.GetResponseStream());
  38.  
  39. Console.WriteLine("Directory Listing:");
  40.  
  41. string line = reader.ReadLine();
  42. while (line != null)
  43. {
  44. Console.WriteLine(line);
  45. line = reader.ReadLine();
  46. }
  47.  
  48. Console.WriteLine("\nenter to exit");
  49. Console.ReadLine();
  50. }
  51. }
  52. }
Add Comment
Please, Sign In to add comment