I found a sample app on the inet that will downloads a text file of the internet. I am trying to modify it to download binary information and save it to a file (an auto updater if you will). I have no intrest in using the inet control. I want to do this strictly with winsock componets. the code i have is below...
that is the seciton of the code i am having problems with. when i download anything binary (images, exe's, etc) it gets corrupted (file size downloaded is smaller by a few kb than that of the org. Does any one have any thoughts as to what is going on? Thanks in advance.
Thanks,
James
![[afro] [afro] [afro]](/data/assets/smilies/afro.gif)
![[mad] [mad] [mad]](/data/assets/smilies/mad.gif)
"Make it idiot-proof and someone will make a better idiot." ~bumper sticker
Code:
If Not m_bHeaderReceived Then
wscHttp.GetData strData, vbString
m_strHttpResponse = m_strHttpResponse & strData
intBreakePosition = InStr(1, m_strHttpResponse, vbCrLf & vbCrLf)
If intBreakePosition Then
m_bHeaderReceived = True
m_lDownloadedBytes = m_lDownloadedBytes - intBreakePosition - 3
vHeaders = Split(Left(m_strHttpResponse, intBreakePosition - 1), vbCrLf)
For Each vHeader In vHeaders
If InStr(1, vHeader, "Content-Length") Then
m_lContentLength = CLng(Mid(vHeader, InStr(1, vHeader, " ") + 1))
End If
' If InStr(1, vHeader, "Content-Type") Then
' Select Case LCase(Mid(vHeader, InStr(1, vHeader, " ") + 1))
' Case "text/html", "application/octet-stream", "text/plain"
' ContentType = 0
' Case "application/x-zip-compressed"
' ContentType = -1
' Case Else
' ContentType = -2
' End Select
' End If
Next
End If
Else
wscHttp.GetData BytBuffer
Debug.Print "recieved: " & bytesTotal & " Buffersize: " & (UBound(BytBuffer) + 1)
Put #1, LPos, BytBuffer
LTotalSize = LTotalSize + UBound(BytBuffer) + 1
LPos = LPos + UBound(BytBuffer) + 1
'm_strHttpResponse = m_strHttpResponse & strData
'If m_lContentLength > 0 Then
ProgressBar1.Value = m_lDownloadedBytes / (m_lContentLength / 100)
StatusBar1.Panels(3).Text = "Downloaded " & m_lDownloadedBytes & _
" from " & m_lContentLength & _
" (" & CInt(m_lDownloadedBytes / (m_lContentLength / 100)) & "%)"
'Else
' StatusBar1.Panels(3).Text = "Downloaded " & m_lDownloadedBytes & " bytes"
'End If
End If
Thanks,
James
![[afro] [afro] [afro]](/data/assets/smilies/afro.gif)
![[mad] [mad] [mad]](/data/assets/smilies/mad.gif)
"Make it idiot-proof and someone will make a better idiot." ~bumper sticker