Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1.         public string getCheckSum(string fileName)
  2.         {
  3.             SessionOptions sessionOptions = new SessionOptions
  4.             {
  5.                 Protocol = Protocol.Ftp,
  6.                 HostName = this.endpointBaseUriString,
  7.                 UserName = this.userName,
  8.                 Password = this.password,
  9.                 FtpMode = FtpMode.Passive
  10.             };
  11.  
  12.             string result = null;
  13.  
  14.             try
  15.             {
  16.                 using (Session session = new Session())
  17.                 {
  18.                     session.Open(sessionOptions);
  19.                     var command = $"XMD5 '{fileName}' SP EP ;";
  20.  
  21.                     var transferResult = session.ExecuteCommand(command);
  22.                     transferResult.Check();
  23.  
  24.                     result = transferResult.Output;
  25.  
  26.                     //var transferResult = session.CalculateFileChecksum("md5", fileName);
  27.                 }
  28.             }
  29.             catch (Exception ex) {
  30.                 throw ex;
  31.             }
  32.  
  33.             return result;
  34.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement