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

Hove

Re: I try to uploading larger files over FTP (MB and GB) and FileProgress always report only 0 and 1.

Putting a description directly into the library would help much more, so that intellisense can pick it up and show you immediately while you are using it.
Hove

Re: I try to uploading larger files over FTP (MB and GB) and FileProgress always report only 0 and 1.

Ok, but having events and properties that imply it can do it does not help in usage, not everyone have time and will to go through documentation, I certainly don't.
martin

Re: I try to uploading larger files over FTP (MB and GB) and FileProgress always report only 0 and 1.

As documented, WinSCP only ever uses Read method of the Stream:
https://winscp.net/eng/docs/library_session_putfile#stream
So it is not aware of the size of the source data, so it cannot calculate the progress. I've update the documentation to state that explicitly:
https://winscp.net/eng/docs/library_session_putfile#remarks
You can still calculate the progress yourself by monitoring reads from the stream.
Hove

I try to uploading larger files over FTP (MB and GB) and FileProgress always report only 0 and 1.

For the entire operation of upload/download it calls FileTransferProgress but with FileProgress=0 until it finishes the upload, then it calls again multiple times incrementing FileProgress all at once. Keep in mind that I am running this operation on background thread (not STA), using Windows Desktop WinForms .NET 8 project and connecting to FileZilla Server 1.8.

session.FileTransferProgress += (s, e) =>
    {
        if (fileTransferState.Canceled)
            e.Cancel = true;
 
        fileTransferState.BitesWritten = (long)(fileTransferState.StreamLength * e.FileProgress);
    };
session.PutFile(readStream, remotePath);