Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 I've 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

 

       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) & " KB's 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

:(

Code today gone tomorrow!
  • *Gurus*
Posted

I don't, but perhaps someone else will.

 

It won't 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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...