Archived Forum Post

Index of archived forum posts

Question:

sftp.ReadFileText32 returns only string 65535 in length ?

Aug 09 '13 at 18:24

When i tried to read a 9 megabyte text file from SFTP server using sftp.ReadFileText32 only 65535 characters were returned ? Why's that ? I just tried sample from chilkat site. http://www.example-code.com/vbdotnet/sftp_readTextFile.asp

Thanks


Answer

I tested the same, but did not reproduce the problem. Verify that the problem still exists in the very latest version of Chilkat. If so, then post the contents of the LastErrorText captured after the call to ReadFileText32.


Answer

I'll verify with the very last version but, in the meantime i just found simple solution for this problem.

This is the original way to read text file :

Dim charset As String
charset = "ansi"
Dim offset32 As Long
offset32 = 0
sFileContent = sftp.ReadFileText32(handle, offset32, numBytes, charset)
If (sFileContent = vbNullString) Then
    MsgBox(sftp.LastErrorText)
    Exit Function
End If

And this is modified way to do the same thing but this time reading whole file.

Dim charset As String
charset = "ansi"
Dim offset32 As Long
offset32 = 0
sFileContent = ""
Do
    sFileContent = sFileContent & sftp.ReadFileText32(handle, offset32, numBytes, charset)
    If (sFileContent = vbNullString) Then
        MsgBox(sftp.LastErrorText)
        Exit Function
    End If
    offset32 = sFileContent.Length
Loop Until sftp.Eof(handle)

Hope this simple modification will help someone else with the same problem.