Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. try
  2. {
  3. SessionOptions sessionOptions = new SessionOptions
  4. {
  5. Protocol = Protocol.Ftp,
  6. HostName = "172.xx.xxx.xx",
  7. UserName = "usersample",
  8. Password = "P@ssw0rd",
  9. PortNumber = 21
  10. };
  11.  
  12. using (Session session = new Session())
  13. {
  14. // Connect
  15. session.Open(sessionOptions);
  16.  
  17. // Download files
  18. TransferOptions transferOptions = new TransferOptions();
  19. transferOptions.TransferMode = TransferMode.Binary;
  20.  
  21. TransferOperationResult transferResult;
  22. transferResult = session.GetFiles("/HST/sample.txt", "C:\Users\john\Documents\SampleFolder\", false, transferOptions);
  23.  
  24. // Throw on any error
  25. transferResult.Check();
  26.  
  27. // Print results
  28. foreach (TransferEventArgs transfer in transferResult.Transfers)
  29. {
  30. Console.WriteLine("Download of {0} succeeded", transfer.FileName);
  31. }
  32.  
  33. Console.ReadLine();
  34. }
  35.  
  36. }
  37. catch (Exception e)
  38. {
  39. Console.WriteLine("Error: {0}", e);
  40. Console.ReadLine();
  41. }
  42.  
  43. SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement