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

Advertisement

Hove
Joined:
Posts:
4

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);

Capture.PNG

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

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.

Reply with quote

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.

Reply with quote

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.

Reply with quote

Advertisement

You can post new topics in this forum