Differences
This shows you the differences between the selected revisions of the page.
| 2013-11-13 | 2013-11-13 | ||
| no summary (80.51.178.3) (hidden) | Restored revision 1375907803. Undoing revision 1384331909. (martin) (hidden) | ||
| Line 166: | Line 166: | ||
| See [[library_com_wsh#vbscript|overall VBScript example]] or [[library_examples|any other VBScript example]]. | See [[library_com_wsh#vbscript|overall VBScript example]] or [[library_examples|any other VBScript example]]. | ||
| - | Imports System | + | ==== [[vba]] VBA Example ==== |
| - | Imports WinSCP | + | See [[library_vb#example|overall VBA example]]. |
| - | + | ||
| - | Friend Class Example | + | |
| - | + | ||
| - | Public Shared Function Main() As Integer | + | |
| - | + | ||
| - | Try | + | |
| - | ' Setup session options | + | |
| - | Dim sessionOptions As New SessionOptions | + | |
| - | With sessionOptions | + | |
| - | .Protocol = Protocol.ftp | + | |
| - | .HostName = "example.com" | + | |
| - | .UserName = "user" | + | |
| - | .Password = "mypassword" | + | |
| - | .SshHostKeyFingerprint = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | + | |
| - | End With | + | |
| - | + | ||
| - | Using session As Session = New Session | + | |
| - | ' Connect | + | |
| - | session.Open(sessionOptions) | + | |
| - | + | ||
| - | ' Upload files | + | |
| - | Dim transferOptions As New TransferOptions | + | |
| - | transferOptions.TransferMode = TransferMode.Binary | + | |
| - | + | ||
| - | Dim transferResult As TransferOperationResult | + | |
| - | transferResult = session.PutFiles("d:\toupload\*", "/home/user/", False, transferOptions) | + | |
| - | + | ||
| - | '; Throw on any error | + | |
| - | transferResult.Check | + | |
| - | + | ||
| - | ················' Print results | + | |
| - | Dim transfer As TransferEventArgs | + | |
| - | ················For Each transfer In transferResult.Transfers | + | |
| - | Console.WriteLine("Upload of {0} succeeded", transfer.FileName) | + | |
| - | Next | + | |
| - | End Using | + | |
| - | + | ||
| - | Return 0 | + | |
| - | Catch e As Exception | + | |
| - | Console.WriteLine("Error: {0}", e) | + | |
| - | Return 1 | + | |
| - | End Try | + | |
| - | + | ||
| - | End Function | + | |
| - | + | ||
| - | End Class | + | |
| ==== [[perl]] Perl Example ==== | ==== [[perl]] Perl Example ==== | ||