I'm getting a VB6 "Out of Memory" error when reading contents from a large file (80MB) into memory to be streamed to a web service using the Microsoft INet Control. The web service only accepts a single "POST" call from the VB6 application to process the entire contents of the file. Below is the code snippet that I am using. The line in red is where I get the "Out of Memory" error. It is happening with "TSO.Read(FileName.Size - 1)". Can anyone help me resolve this issue?



Dim FSO As FileSystemObject
Dim TSO As TextStream
Dim FileName As File
Dim strImportFile As String

strImportFile = GetImportFileName() ' gets the import filename
HttpRequestHeader = GetRequestHeader() ' gets the http request header (25 character string)

If Trim(strImportFile) <> vbNullString Then
Set FSO = New FileSystemObject
Set FileName = FSO.GetFile(strImportFile)
Set TSO = FileName.OpenAsTextStream(ForReading, TristateFalse)

'stream the data from the file to a webservice using Microsoft INet Control

m_Inet.Execute , "POST", TSO.Read(FileName.Size - 1), HttpRequestHeader

TSO.Skip FileName.Size
End If

Set TSO = Nothing
Set FSO = Nothing