Progress on downloads HELP!

a_jam_sandwich

Well-known member
Joined
Dec 10, 2002
Messages
367
Location
Uk
I require to download a set of files i.e this is a updater for changes withing the database to be downloaded from the internet.

I need to add a progress meter into program Ive tried looking for the right event but with no joy.

The code below works as it was taken from 101 samples of VB.NET anyway

Code:
        Dim fs As FileStream	
        Dim req As WebRequest

        Try
            req = WebRequest.Create("http://www.website.com/filename.pdf")

            req.Method = "GET"

            Dim rsp As WebResponse = req.GetResponse()

            Try
 
                fs = New FileStream("ReceivedXMLFile.pdf", FileMode.Create)

                CopyData(rsp.GetResponseStream(), fs)

                Msgbox (CStr(rsp.ContentLength / 1024) & " KBs Downloaded")

            Catch exp As Exception
                MessageBox.Show(exp.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop)

            Finally

                If Not rsp Is Nothing Then rsp.GetResponseStream.Close()
                If Not fs Is Nothing Then fs.Close()

Please help

Cheers
:(
 
You may well find yourself having to write the code to connect to the webserver using a Socket or TcpClient yourself, Im not aware of a framework method to download files from http and give transfer progress.
 
I dont, but perhaps someone else will.

It wont get more complex than reading the HTTP RFC, connecting to the webserver on port 80, issuing a GET request for the file, examining the Content-Length header then storing the data as you receive it.
 
Back
Top