Home > Software engineering >  VB to download binary stream file how to do?
VB to download binary stream file how to do?

Time:11-30

Recently met not in development, due to being self-taught, some things also can not contact, now project has a function, is access to HTTP return flow of a binary file, after I submitted a htto server returns a binary stream file to me, (this is the zip format file stream, the server returns the given binary stream), and how to use VB to save this binary stream file to your local? File is saved. Zip format, anyone can do? Contact me, QQ: 88600246!

CodePudding user response:

 GetChunk method, StateChanged event example 
In the example in the StateChanged events GetChunk method to retrieve a piece of data, the example USES the Select Case statement to decide how to deal with every possible condition, this example assumes the form of a TextBox control, called txtData

Private Sub Inet1_StateChanged (ByVal State As an Integer)
'State=12, use GetChunk method to retrieve server response,
'this example assumes that the data as the text type,

Select the Case State
'... No list other situation,

Case icResponseReceived '12
Dim vtData As the Variant 'data variables,
Dim strData As String: strDatahttps://bbs.csdn.net/topics/=""
Dim bDone As Boolean: bDone=False

'the first block,
VtData=https://bbs.csdn.net/topics/Inet1.GetChunk (1024, icString)
DoEvents
The Do While Not bDone
StrData=https://bbs.csdn.net/topics/strData & vtData
DoEvents
'in the next block,
VtData=https://bbs.csdn.net/topics/Inet1.GetChunk (1024, icString)
Then If Len (vtData)=0
BDone=True
End the If
Loop

TxtData. Text=strData
End the Select

End Sub

CodePudding user response:


GetChunk method (Internet Transfer control)


Retrieve data from the StateChanged events, as the Execute method of the GET operation to call after using this method,

Syntax

Object. GetChunk (size, datatype [])

Get attribute grammar contains the following parts:

Part of the description
Object expression, and its value is "applied" in the list of objects,
The Size required, long integer expression, decided to the Size of the block being retrieved,
Datatype optional, integer, decided to be retrieved data types, as shown in the "Settings" below,


Set the value

Datatype setting values:

Constant value description
IcString 0, the default, the data as a string to retrieve,
IcByteArray 1 to retrieve the data as a byte array,


The return type

The Variant

Description

In the event of an StateChanged use GetChunk method, when the State property to icResponseCompleted (12), using GetChunk method to retrieve the contents of the buffer,

CodePudding user response:

Now is already obtained data flow how to do?

CodePudding user response:

File operations of VB6 statements,
Open disk files for binary as # 1
Put # 1, and arrBuff
The close

The absolute path to the file is best integrated into ", "arrBuff refers to store an array of bytes of data flow,

CodePudding user response:

If the data flow is compressed, it is necessary to write to the file after decompression, can use the interface function to extract the Zlib,
  • Related