Can't get the Internet Transfer Control to work

F

Franco

I'm using VB 2005. I want to use the Inet control to get a file from a
server via HTTP.

The code to send the request is:

AxInet1.Execute("http://www.thewebsite.com/thefile.zip", "GET", "", "")

And the code to handle the response event is:

Private Sub AxInet1_StateChanged(ByVal sender As Object, ByVal e As
AxInetCtlsObjects.DInetEvents_StateChangedEvent) Handles
AxInet1.StateChanged
Dim vtData As Object
Dim intFile As Integer
intFile = FreeFile()
If (e.state = InetCtlsObjects.StateConstants.icResponseReceived)
Then
FileOpen(intFile, "thefile.zip", OpenMode.Binary,
OpenAccess.Write)
vtData = AxInet1.GetChunk(1024,
InetCtlsObjects.DataTypeConstants.icByteArray)
Do While Len(vtData) > 0
FilePutObject(intFile, vtData)
vtData = AxInet1.GetChunk(1024,
InetCtlsObjects.DataTypeConstants.icByteArray)
Loop
FilePutObject(intFile, vtData)
FileClose(intFile)
End If
End Sub

I get the "response received" event, but when I call the first
"GetChunk", it just gets stuck there. What am I doing wrong? Thanks in
advance for any suggestions.
 
H

Herfried K. Wagner [MVP]

Franco said:
I'm using VB 2005. I want to use the Inet control to get a file from a
server via HTTP.

I suggest to use 'System.Net.WebClient' instead, which has a 'DownloadFile'
method.
 
A

aaron.kempf

does this system.net.webclient inherit proxy settings from IE?

I thnk that there are a dozen ways to download stuff in the vb6 world
that were better than ITC.. i just figured that the guy has a REASON to
be using ITC instead of ServerXmlHttp for example

-Aaron
 
F

Franco

I tried to use the Internet Transfer Control because that's the only
way I know, but if there are easier and/or better ways, I'll gladly use
one of those. Could you explain a little more what those other ways
are? Thanks.
 
A

aaron.kempf

I reccomend the .NET library that he's talking about

but ServerXmlHttp is a great tool also

how much stuff are you downloading; anyways?

-Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top