Differences
This shows you the differences between the selected revisions of the page.
library_session_filetransferprogress 2017-10-04 | library_session_filetransferprogress 2024-09-12 (current) | ||
Line 1: | Line 1: | ||
====== Session.FileTransferProgress Event ====== | ====== Session.FileTransferProgress Event ====== | ||
- | Occurs during file tranfer to report transfer progress. Occurs as part of either ''[[library_session_getfiles|Session.GetFiles]]'', ''[[library_session_putfiles|Session.PutFiles]]'' or ''[[library_session_synchronizedirectories|Session.SynchronizeDirectories]]''. | + | Occurs during file transfer to report transfer progress. Occurs as part of either ''[[library_session_getfiles|Session.GetFiles]]'', ''[[library_session_putfiles|Session.PutFiles]]'' (and other derived download and upload methods) or ''[[library_session_synchronizedirectories|Session.SynchronizeDirectories]]''. |
===== Syntax ===== | ===== Syntax ===== | ||
<code csharp *> | <code csharp *> | ||
- | public delegate void FileTransferProgressEventHandler(object sender, FileTransferProgressEventArgs e); | + | public delegate void FileTransferProgressEventHandler( |
+ | ····object sender, | ||
+ | ···FileTransferProgressEventArgs e | ||
+ | ); | ||
public event FileTransferredEventHandler FileTransferred; | public event FileTransferredEventHandler FileTransferred; | ||
</code> | </code> | ||
Line 11: | Line 14: | ||
<code vbnet *> | <code vbnet *> | ||
Public Delegate Sub FileTransferProgressEventHandler( | Public Delegate Sub FileTransferProgressEventHandler( | ||
- | ByVal sender As Object, ByVal e As FileTransferProgressEventArgs) | + | sender As Object, |
+ | ···e As FileTransferProgressEventArgs | ||
+ | ) | ||
Public Custom Event FileTransferred As FileTransferredEventHandler | Public Custom Event FileTransferred As FileTransferredEventHandler | ||
</code> | </code> | ||
Line 25: | Line 30: | ||
===== [[example]] Examples ===== | ===== [[example]] Examples ===== | ||
+ | |||
==== [[csharp]] C# Example ==== | ==== [[csharp]] C# Example ==== | ||
<code csharp> | <code csharp> | ||
Line 43: | Line 49: | ||
UserName = "user", | UserName = "user", | ||
Password = "mypassword", | Password = "mypassword", | ||
- | SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..." | + | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
}; | }; | ||
Line 57: | Line 63: | ||
{ | { | ||
// Download files and throw on any error | // Download files and throw on any error | ||
- | session.GetFiles("/home/martin/public_html/*", "d:\\backup\\").Check(); | + | session.GetFiles("/home/martin/public_html/*", @"d:\backup\").Check(); |
} | } | ||
finally | finally | ||
Line 114: | Line 120: | ||
.UserName = "user" | .UserName = "user" | ||
.Password = "mypassword" | .Password = "mypassword" | ||
- | .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..." | + | .SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
End With | End With | ||
Line 145: | Line 151: | ||
Private Shared Sub SessionFileTransferProgress( | Private Shared Sub SessionFileTransferProgress( | ||
- | ByVal sender As Object, ByVal e As FileTransferProgressEventArgs) | + | sender As Object, e As FileTransferProgressEventArgs) |
' New line for every new file | ' New line for every new file | ||
If (_lastFileName IsNot Nothing) AndAlso (_lastFileName <> e.FileName) Then | If (_lastFileName IsNot Nothing) AndAlso (_lastFileName <> e.FileName) Then | ||
Line 200: | Line 206: | ||
UserName = "user" | UserName = "user" | ||
Password = "mypassword" | Password = "mypassword" | ||
- | SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..." | + | SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." |
} | } | ||
Line 229: | Line 235: | ||
exit 0 | exit 0 | ||
} | } | ||
- | catch [Exception] | + | catch |
{ | { | ||
Write-Host "Error: $($_.Exception.Message)" | Write-Host "Error: $($_.Exception.Message)" | ||
Line 251: | Line 257: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | ==== Real-Life Example ==== | ||
+ | |||
+ | * [[library_example_winforms_progressbar|*]]. | ||
+ |