Private Sub Command1_Click()
Inet1.AccessType = icUseDefault Inet1.URL = "http://example.microsoft.com/somefile.exe" Inet1.Execute , "GET" End Sub Private Sub Inet1_StateChanged(ByVal State As Integer) Dim vtData As Variant Select Case State ' ... Other cases not shown. Case icResponseCompleted ' 12 Dim bDone As Boolean: bDone = False Dim tempArray() As Byte filesize = Inet1.GetHeader("Content-length") contenttype = Inet1.GetHeader("Content-type") Open "C:\somefile.exe" For Binary Access Write As #1 ' Get first chunk. vtData = Inet1.GetChunk(1024, icByteArray) DoEvents If Len(vtData) = 0 Then bDone = True End If Do While Not bDone tempArray = vtData Put #1, , tempArray ' Get next chunk. vtData = Inet1.GetChunk(1024, icByteArray) DoEvents If Len(vtData) = 0 Then bDone = True End If Loop Close #1 End Select End Sub A Variant containing an array requires 12 bytes more than the array alone. This extra data is used to describe the contents of the variant. If the variant is written directly to disk, the 12 extra bytes are written to disk as well as the array. To avoid this situation, assign the variant to an intermediate byte array and write that array to disk. The following code illustrates this method: |