Differences

This shows you the differences between the selected revisions of the page.

2012-01-10 2012-01-11
Protocol not Protocols (martin) using Session, no need to check for an error (martin)
Line 57: Line 57:
            sessionOptions.SshHostKey = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx";             sessionOptions.SshHostKey = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx";
-            // Connect +            using (Session session = new Session()) 
-············Session session = new Session(); +           
-            session.Open(sessionOptions);+                // Connect 
 +················session.Open(sessionOptions);
-············// Upload files +················// Upload files 
- ···········TransferOptions transferOptions = new TransferOptions(); + ···············TransferOptions transferOptions = new TransferOptions(); 
- ···········transferOptions.TransferMode = TransferMode.Binary;+ ···············transferOptions.TransferMode = TransferMode.Binary;
-············OperationResult<TransferEventArgs> transferResult; +················OperationResult<TransferEventArgs> transferResult; 
- ···········transferResult = session.PutFiles(@"d:\toupload\*", "/home/user/", false, transferOptions);+ ···············transferResult = session.PutFiles(@"d:\toupload\*", "/home/user/", false, transferOptions);
-············// Throw on any error +················// Throw on any error 
- ···········transferResult.Check();+ ···············transferResult.Check();
-············// Print results +················// Print results 
- ···········foreach (TransferEventArgs transfer in transferResult.Operations+ ···············foreach (TransferEventArgs transfer in transferResult.Operations)
-            { +
-                if (transfer.Error == null)+
                {                 {
                    Console.WriteLine("Upload of {0} succeeded", transfer.FileName);                     Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
-                } 
-                else 
-                { 
-                    Console.WriteLine("Upload of {0} failed: {1}", transfer.FileName, transfer.Error); 
                }                 }
            }             }

Last modified: by martin