Archived Forum Post

Index of archived forum posts

Question:

GetFile fails, but file downloaded successfully; wrong expectedByteCount; right downloadedByteCount

Jul 05 '17 at 04:43

I've upgraded my ftp2 activex control at the last version in last days; during my tests in some case I had some GetFile error message that with earlier version I did not have; there were messages like the one following. As you see: 1) Xml report says that "226-File successfully transferred" 2) Xml report says that "<downloadedbytecount>43</downloadedbytecount>" 3) Xml report says that "<expectedbytecount>325985</expectedbytecount>" so it seems that this error is about "<error>Downloaded byte count less than expected byte count.</error>" 4) But if I call Ftp.GetSizeByName, I've exactly the dimension corresponding to "<downloadedbytecount>" Have you ever find siyuation like this? Thank you

<ChilkatLog>
    <GetFile>
        <DllDate>May 25 2017</DllDate>
        <ChilkatVersion>9.5.0.68</ChilkatVersion>
        <Architecture>Little Endian; 32-bit</Architecture>
        <Language>.NET 4.0</Language>
        <VerboseLogging>0</VerboseLogging>
        <ProgressMonitoring>
            <enabled>yes</enabled>
            <heartbeatMs>0</heartbeatMs>
            <sendBufferSize>65536</sendBufferSize>
        </ProgressMonitoring>
        <downloadToFile>
            <localFilename>C:\Copatlife\PIGRECO_UPD\201706271737_TMP\MOBILGAM_PI_HORIZON\CONFIGURAZIONE\TypologyGroupList.ARG.BAK</localFilename>
            <downloadToOutput2>
                <modeZ>0</modeZ>
                <binaryMode>1</binaryMode>
                <setupDataConnection>
                    <info>passive transfer mode</info>
                    <setupPassiveDataSocket>
                        <sendCommand>
                            <sendingCommand>PASV</sendingCommand>
                        </sendCommand>
                        <readCommandResponse>
                            <replyLineQP>227 Entering Passive Mode (62,149,141,10,191,120)</replyLineQP>
                        </readCommandResponse>
                        <dataConnect>
                            <hostname>62.149.141.10</hostname>
                            <port>49016</port>
                            <socketOptions>
                                <SO_SNDBUF>262144</SO_SNDBUF>
                                <SO_RCVBUF>4194304</SO_RCVBUF>
                                <TCP_NODELAY>0</TCP_NODELAY>
                                <SO_KEEPALIVE>0</SO_KEEPALIVE>
                            </socketOptions>
                            <dataConnectSuccess>1</dataConnectSuccess>
                        </dataConnect>
                    </setupPassiveDataSocket>
                </setupDataConnection>
                <sendCommand>
                    <sendingCommand>RETR TypologyGroupList.ARG.BAK</sendingCommand>
                </sendCommand>
                <readCommandResponse>
                    <replyLineQP>150 Accepted data connection</replyLineQP>
                </readCommandResponse>
                <downloadRate>0</downloadRate>
                <totalNumBytesReceived>43</totalNumBytesReceived>
                <receiveTimeMs>Elapsed time: 31 millisec</receiveTimeMs>
                <info>Data connection closed.</info>
                <readCommandResponse>
                    <replyLineQP>226-File successfully transferred</replyLineQP>
                    <replyLineQP>226 0.000 seconds (measured here), 130.37 Kbytes per second</replyLineQP>
                </readCommandResponse>
                <error>Downloaded byte count less than expected byte count.</error>
                <downloadedByteCount>43</downloadedByteCount>
                <expectedByteCount>325985</expectedByteCount>
            </downloadToOutput2>
            <downloadToOutput>Elapsed time: 93 millisec</downloadToOutput>
        </downloadToFile>
        <error>Failed.</error>
    </GetFile>
</ChilkatLog> 

Answer

This would happen when the FTP2 component knows the remote file size but receives a different amount of data.

Maybe you have a situation where you previously downloaded a directory listing (either implicitly or explicitly), then something caused the size of the file on the server to change, and then you tried downloading.

You can try two things:

1) Set the ftp2.AutoGetSizeForProgress property = 0. (0 is the default, so this would only apply if you previously set the property = 1)

2) Call the ftp2.ClearDirCache() method before calling GetFile.


Answer

Hi, thank you for your reply; I've try your suggested solutions, but unfortunately I had the same messages like before; do you have any kind of other suggestion for this case? Thanks