Advertisement
Guest User

Untitled

a guest
Feb 12th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. Log.Info("Retrieving DC DMV Response File");
  2.  
  3. string source = @"216.12.134.169";
  4. string destination = @"/users/BMICI/BOB_Outbound/";
  5. string host = "216.12.134.169";
  6. string username = "BMICI";
  7. string password = "Pwd_Bmici35";
  8. int port = 21; //Port 22 is defaulted for SFTP upload
  9.  
  10.  
  11. try
  12. {
  13. using (SftpClient client = new SftpClient(host, port, username, password))
  14. {
  15. client.Connect();
  16. client.ChangeDirectory(destination);
  17. using (FileStream fs = new FileStream(source, FileMode.Open))
  18. {
  19. client.BufferSize = 4 * 1024;
  20. client.UploadFile(fs, Path.GetFileName(source));
  21. }
  22. }
  23.  
  24. //using (var conn = new SftpClient(ConfigurationManager.AppSettings["DCDMVServer"],
  25. // Convert.ToInt32(ConfigurationManager.AppSettings["DCDMVPort"], CultureInfo.InvariantCulture),
  26. // ConfigurationManager.AppSettings["DCDMVUsername"],
  27. // ConfigurationManager.AppSettings["DCDMVPassword"]))
  28. //{
  29. // conn.Connect();
  30.  
  31. // Log.Info("Downloading DC DMV return files from DC MVA");
  32.  
  33. // foreach (var file in conn.ListDirectory("users/BMICI/BOB_Outbound"))
  34. // {
  35. // if (file.IsDirectory)
  36. // {
  37. // continue;
  38. // }
  39.  
  40. // var downloadPath = Path.Combine(ConfigurationManager.AppSettings["DMVFilesFromPoint"],
  41. // "DCMVA Returns", file.Name);
  42. // using (var fs = File.OpenWrite(downloadPath))
  43. // {
  44. // Log.DebugFormat("Downloading {0} to {1}", file.FullName, downloadPath);
  45. // conn.DownloadFile(file.FullName, fs);
  46. // }
  47. // file.Delete();
  48. // }
  49. //}
  50. }
  51. catch (Exception ex)
  52. {
  53. Log.Error("DC DMV Reponse File Download error", ex);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement