Using GetChunk w/ Inet Control

byrne1
01-24-2002, 07:45 AM
I am having trouble using the GetChunk command. I am attempting to transfer an ASCII file from the mainframe to my PC. When I issue the GET command the file comes over as binary. When I use the GetChunk command in the icResponseCompleted event, there is no data for me to get. What I end up with is a binary file that's 296KB and an empty text file (tesstt.txt).

My code is as follows:

Sub Get_Data()
Inet1.URL = Text2
Inet1.UserName = txtUserID
Inet1.Password = txtPword
Inet1.OpenURL
Inet1.Execute , "get '" & HostDSN & "'" & " " & PCFile
End Sub

Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case icResponseCompleted
Dim vtData As Variant ' Data variable.
Dim strData As String: strData = ""
Dim bDone As Boolean: bDone = False
Me.lblResponse.Caption = "GetChunking"
'Get first chunk.
vtData = Inet1.GetChunk(1024, icString)
DoEvents
Do While Not bDone
strData = strData & vtData
DoEvents
' Get next chunk.
vtData = Inet1.GetChunk(1024, icString)
If Len(vtData) = 0 Then
bDone = True
End If
Open "c:\tesstt.txt" For Append As #1
Print #1, strData
Close #1
Loop
Me.lblResponse.Caption = "GotChunked"
End Select
End Sub

Flyguy
01-24-2002, 07:47 AM
There was one posting before some time ago about the same problem.
I think we came to the conclusion that the Inet control always transfers in binary mode and you have to convert from binary to ascii yourself. Which is not that difficult.

byrne1
01-24-2002, 07:50 AM
OK, so can you tell me how to do this, or point me in the right direction? Thanks!

Flyguy
01-24-2002, 08:04 AM
What does the binary file looks like?
Is it just missing Linefeeds or Carriage returns?
Or is it some other format?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum