Differences
This shows you the differences between the selected revisions of the page.
2016-06-27 | 2016-06-27 | ||
no summary (49.231.225.108) (hidden) | Restored revision 1450374611. Undoing revision 1467016110. (martin) (hidden) | ||
Line 35: | Line 35: | ||
By default the download starts on foreground, blocking the WinSCP window until it finishes. Learn how to schedule the [[transfer_queue|background transfer]]. | By default the download starts on foreground, blocking the WinSCP window until it finishes. Learn how to schedule the [[transfer_queue|background transfer]]. | ||
- | Imports WinSCP | + | ===== Automating Download ===== |
- | + | To automate the file download, use the scripting command ''[[scriptcommand_get|get]]'' or .NET assembly method ''[[library_session_getfiles|Session.GetFiles]]''. | |
- | Friend Class Example | + | |
- | + | ||
- | Public Shared Function Main() As Integer | + | |
- | + | ||
- | Try | + | |
- | ' Setup session options | + | |
- | Dim sessionOptions As New SessionOptions | + | |
- | With sessionOptions | + | |
- | .Protocol = Protocol.Sftp | + | |
- | .HostName = "http://202.8.78.82" | + | |
- | .UserName = "gbadmin" | + | |
- | .Password = "GisServer2016" | + | |
- | .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | + | |
- | End With | + | |
- | + | ||
- | Using session As New Session | + | |
- | ' Connect | + | |
- | session.Open(sessionOptions) | + | |
- | + | ||
- | ' Download files | + | |
- | ················Dim transferOptions As New TransferOptions | + | |
- | ················transferOptions.TransferMode = TransferMode.Binary | + | |
- | + | ||
- | ················Dim transferResult As TransferOperationResult | + | |
- | transferResult = session.GetFiles("/var/lib/mysql/relay-log.info", "d:\download\", False, transferOptions) | + | |
- | + | ||
- | ···············' Throw on any error | + | |
- | ················transferResult.Check() | + | |
- | + | ||
- | ················' Print results | + | |
- | For Each transfer In transferResult.Transfers | + | |
- | Console.WriteLine("Download 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 | + | |
===== [[unc]] Downloading Files To UNC Paths (Network shares) ===== | ===== [[unc]] Downloading Files To UNC Paths (Network shares) ===== | ||
While WinSCP cannot browse UNC paths (network shares) in local [[ui_file_panel|panel]] of [[ui_commander|Commander interface]], it can download files therein. You can [[#dragdrop|drag]] the files to Windows Explorer or another application, you can use UNC paths in [[scripting]], you can [[ui_copy#target_directory|type target UNC path manually]], or use any other mean of downloading as described on this page. | While WinSCP cannot browse UNC paths (network shares) in local [[ui_file_panel|panel]] of [[ui_commander|Commander interface]], it can download files therein. You can [[#dragdrop|drag]] the files to Windows Explorer or another application, you can use UNC paths in [[scripting]], you can [[ui_copy#target_directory|type target UNC path manually]], or use any other mean of downloading as described on this page. |