Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

If there's a failure, the tor.Check() throws. So should actually never get to the // fail branch (unless you selected no files for transfer, but than it's not a failure). On the other hand the tor.Transfers.Count > 0 is not an indication of success, but possibly of a partial success only. But again, mere fact that tor.Check() did not throw is an indication of success.
huahsin68

Can I perform the check using the following code?

TransferOperationResult tor = session.PutFiles(...);

tor.Check();

if( tor.Transfers.Count > 0 )
{
   // suscess
}
else
{
   // fail
}


I just test on the code and it works. But I wasn't sure whether this is the right way of checking?
martin

Re: How to track when a file is fail to transfer?

No. The code that checks if there is any failure is transferResult.Check();. Alternatively check TransferOperationResult.Failures.

See https://winscp.net/eng/docs/library_session#results
huahsin68

How to track when a file is fail to transfer?

According to the sample code in C# from this link > https://winscp.net/eng/docs/library#csharp, there is a piece that tracking whether the file is successfully transfer. As shown here:

// Print results

foreach (TransferEventArgs transfer in transferResult.Transfers)
{
    Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
}


I did some experiment on this code, I found out that this code unable to track when the file was fail to transfer. May I know how could I track when a file is failed to transfer?