Arun D
Arun D

Reputation: 279

Cancel file transfers while transferring file to destination

I have used Winscp for file transferring and got details file transfer progress like below link,

File transfer details binding continuously until file transfered in window using WPF

and transfer code link below

https://winscp.net/eng/docs/library

But i need to cancel file transferring. Please give your suggestion.

Upvotes: 3

Views: 721

Answers (2)

Martin Prikryl
Martin Prikryl

Reputation: 202360

You can use FileTransferProgressEventArgs.Cancel:

bool cancel = false; // set to true to cancel the transfer

session.FileTransferProgress +=
    (sender, e) =>
    {
        if (cancel)
        {
            e.Cancel = true;
        }
    };

session.PutFiles(localPath, remotePath).Check();

Upvotes: 0

William Cross
William Cross

Reputation: 312

To my understanding the only way to achieve this is to abort the current session.

link: https://winscp.net/eng/docs/library_session_abort

Upvotes: 2

Related Questions