Xceed FTP Library Documentation
File size workarounds

When receiving files with the ReceiveFile method, some FTP servers will not provide the library with the file size of the file currently file being received, and therefore the FileTransferStatus event's lFileSize and nBytesPercent parameters will contain the value 0.

If you require these particular statistics, you can perform any of the following workarounds in order to make sure you get them:

Technique 1

Use the ReceiveMultipleFiles method instead of the ReceiveFiles method. The ReceiveMultipleFiles method requests a complete listing from the FTP server before downloading any files. The library therefore obtains the file sizes of each file being downloaded and can then provide these statistics during the FileTransferStatus event. If you use this technique, keep in mind that the receive operation is slightly slower (due to the extra listing operation) and that the only way to specify the local filename (if you want to rename the incoming file) is to modify the sLocalFilename parameter of the ReceivingFile event.

Technique 2

You can request a listing of files using the ListFolderContents method, obtain the file size yourself, call the ReceiveFile method, and then when the ReceivingFile event is triggered, change the lFileSize parameter. The FileTransferStatus event parameters will then contain the correct file size and percentage information.