Hi,<br>
<br>
Are you making sure you wait for each file to finish downloading before you give an instruction to the control to download another?<br>
<br>
Mike <p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href=
Not exactly. The reason is because of requestimeout error. I changed the code using the Inet_Statechanged event to download per 1024 bytes. I am left in a wait state. could you help?
MikeLacey<br>
the code below is in the inet1_Statechanged event. Can you take a look at it.<br>
private sub Inet1_StateChanged(Byval State as Integer)<br>
Dim bDone As Boolean<br>
Dim vByte() As Byte<br>
Dim bytAppend() As Byte<br>
Dim intFileNum As Integer<br>
<br>
select case <br>
case icError<br>
case icResponseCompleted<br>
vByte() = Inet1.GetChunk(1024, icByteArray)<br>
DoEvents<br>
<br>
Do While Not bDone<br>
'bytAppend = vByte<br>
vByte() = Inet1.GetChunk(1024, icByteArray)<br>
DoEvents<br>
<br>
If UBound(vByte()) = 0 Then<br>
bDone = True<br>
End If<br>
Loop<br>
intFileNum = FreeFile<br>
Open (Trim$(strDownloadFile)) For Binary As #intFileNum<br>
Put #intFileNum, , vByte()<br>
Close #intFileNum<br>
end select<br>
end sub
Your code looks ok - pretty close to stuff in VB Books Online (and pretty close to mine therefore)<br>
<br>
If I get a timeout error - i retry the operation<br>
<br>
on error resume next<br>
<br>
do <br>
Call something_that_might_fail<br>
while err<>0<br>
<br>
good idea to put a count in there as well - you don't want it to go on forever if it can't get a good connection<br>
<br>
Mike<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href=
I am already dealing with the timeout error by setting the Inet requestimeout property to infinity (0). The problem is when I save the few binary chunks of data to file for some reasons it's not saving all of them. It is saving a portion of the file.<br>
<br>
I think the code is okay. But with regards to the books online (with regards to dealing with strings) it looks something like this.<br>
<br>
data = Inet.Getchunk(1024, icString)<br>
doevents<br>
<br>
while not bDone<br>
'Here it is right here, how do I add the next portion <br>
'to the byteArray, Do I use MS array functions like<br>
'redim (and if so - to what). I hope I'm making myself<br>
'a bit clear here. Other applications have a way of pushing<br>
'elements at the end of an array. Does VB have this 'capability.<br>
str = str & data<br>
data = Inet.Getchunk(1024,icString)<br>
<br>
while inet.stillexecuting<br>
doevents<br>
wend<br>
<br>
if bDone = true then exit sub<br>
wend<br>
'Exit Statechanged event
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.