I have created project to transferring file from client to server. I have done file transferred and got file transferred details such as file name (something.avi) and percentage (10%) of file transferred like below, Whenever I'm transferring a file, I'm using below event handler for knowing the file transferred details.
private static void SessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
{
// New line for every new file
if ((_lastFileName != null) && (_lastFileName != e.FileName))
{
Console.WriteLine();
}
// Print transfer progress
Console.Write("\r{0} ({1:P0})", e.FileName, e.FileProgress);
// Remember a name of the last file reported
_lastFileName = e.FileName;
}
private static string _lastFileName;
I need to bind this transferred details in window. I have done binding while file transferred. But I need how to bind every second file transferred details in window using WPF. Because I need to show progress of file transferring.
The WinSCP .NET assembly Session.FileTransferProgress
event is triggered continuously.
So all you need to do, is to update your control in the event handler.
As the event is triggered on a background thread, you need to use Invoke
. See Updating GUI (WPF) using a different thread.
For an example WinForms code, see WinSCP article Displaying FTP/SFTP transfer progress on WinForms ProgressBar. With WPF, the code will be very similar.