Home All Groups Group Topic Archive Search About

Can't get the Internet Transfer Control to work

Author
4 Oct 2006 7:08 PM
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.

Author
4 Oct 2006 8:45 PM
Herfried K. Wagner [MVP]
"Franco" <cumin***@yahoo.com> schrieb:
> 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.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>