PC Review


Reply
Thread Tools Rate Thread

Downloading file from web server

 
 
Richard L Rosenheim
Guest
Posts: n/a
 
      24th Oct 2004
I know that I can download a file from a web server by using the
WebClient.DownloadFile method. But, does anyone know of an example of
downloading a file from a web server with the ability to monitor the
download progress?

I'm looking for either the number of bytes downloaded and/or percentage
completed.

TIA


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      24th Oct 2004
"Richard L Rosenheim" <(E-Mail Removed)> schrieb:
> But, does anyone know of an example of
> downloading a file from a web server with the ability
> to monitor the download progress?


<URL:http://groups.google.de/groups?q=dotnet+download+file+progress>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


 
Reply With Quote
 
Richard L Rosenheim
Guest
Posts: n/a
 
      24th Oct 2004
Thanks, I found a Compact Framework example that looks promising. I should
be able to utilize the code, after possibly a little conversion.

Richard


"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Richard L Rosenheim" <(E-Mail Removed)> schrieb:
> > But, does anyone know of an example of
> > downloading a file from a web server with the ability
> > to monitor the download progress?

>
> <URL:http://groups.google.de/groups?q=dotnet+download+file+progress>
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>
>
>



 
Reply With Quote
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      24th Oct 2004
Hi,

Here is a quick example. Add these import statements.

Imports System.Net

Imports System.IO



Sample code



Dim request As WebRequest

Dim response As WebResponse

Dim reader As Stream

Dim writer As Stream

Dim data(1023) As Byte

Dim count As Integer

Dim total As Integer

Me.Show()

Me.Text = "Downloading file ....."

Application.DoEvents()

request =
WebRequest.Create("http://www.onteorasoftware.com/downloads/multigrids.zip")

response = request.GetResponse()

reader = response.GetResponseStream()

ProgressBar1.Maximum = CInt(response.ContentLength)

ProgressBar1.Value = 0

total = 0

writer = File.Create("mylocaldata.zip")

While True

count = reader.Read(data, 0, 1024)

If count <= 0 Then

Exit While

End If

writer.Write(data, 0, count)

total += 1024

If total < ProgressBar1.Maximum Then ProgressBar1.Value = total

Application.DoEvents()

End While

reader.Close()

writer.Close()



Ken

--------------------------

"Richard L Rosenheim" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
I know that I can download a file from a web server by using the
WebClient.DownloadFile method. But, does anyone know of an example of
downloading a file from a web server with the ability to monitor the
download progress?

I'm looking for either the number of bytes downloaded and/or percentage
completed.

TIA



 
Reply With Quote
 
Richard L Rosenheim
Guest
Posts: n/a
 
      24th Oct 2004
Thanks.

Richard


"Ken Tucker [MVP]" <(E-Mail Removed)> wrote in message
news:ui%(E-Mail Removed)...
> Hi,
>
> Here is a quick example. Add these import statements.
>
> Imports System.Net
>
> Imports System.IO
>
>
>
> Sample code
>
>
>
> Dim request As WebRequest
>
> Dim response As WebResponse
>
> Dim reader As Stream
>
> Dim writer As Stream
>
> Dim data(1023) As Byte
>
> Dim count As Integer
>
> Dim total As Integer
>
> Me.Show()
>
> Me.Text = "Downloading file ....."
>
> Application.DoEvents()
>
> request =
>

WebRequest.Create("http://www.onteorasoftware.com/downloads/multigrids.zip")
>
> response = request.GetResponse()
>
> reader = response.GetResponseStream()
>
> ProgressBar1.Maximum = CInt(response.ContentLength)
>
> ProgressBar1.Value = 0
>
> total = 0
>
> writer = File.Create("mylocaldata.zip")
>
> While True
>
> count = reader.Read(data, 0, 1024)
>
> If count <= 0 Then
>
> Exit While
>
> End If
>
> writer.Write(data, 0, count)
>
> total += 1024
>
> If total < ProgressBar1.Maximum Then ProgressBar1.Value = total
>
> Application.DoEvents()
>
> End While
>
> reader.Close()
>
> writer.Close()
>
>
>
> Ken
>
> --------------------------
>
> "Richard L Rosenheim" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> I know that I can download a file from a web server by using the
> WebClient.DownloadFile method. But, does anyone know of an example of
> downloading a file from a web server with the ability to monitor the
> download progress?
>
> I'm looking for either the number of bytes downloaded and/or percentage
> completed.
>
> TIA
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get size of file on ftp server before downloading Adam Microsoft Dot NET Framework 2 11th Mar 2010 04:36 AM
Downloading a text file from a Web Server Rob Microsoft Dot NET 1 27th Dec 2005 05:31 AM
downloading file get empty from one server. =?Utf-8?B?RnJhbms=?= Microsoft ASP .NET 7 7th Dec 2005 06:21 PM
Downloading file from Web Server to Client cbanks@bjtsupport.com Microsoft ASP .NET 1 3rd Dec 2005 08:54 AM
Downloading file from remote server with 'Save As' dialogue kevin Microsoft C# .NET 5 10th Dec 2004 03:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:17 AM.