Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2004

Tip: Looking for answers? Try searching our database.

Downloading file from web server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard L Rosenheim - 24 Oct 2004 14:11 GMT
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
Herfried K. Wagner [MVP] - 24 Oct 2004 14:37 GMT
"Richard L Rosenheim" <richard@rlr.com> 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>

Signature

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

Richard L Rosenheim - 24 Oct 2004 14:51 GMT
Thanks, I found a Compact Framework example that looks promising.  I should
be able to utilize the code, after possibly a little conversion.

Richard

> "Richard L Rosenheim" <richard@rlr.com> 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>
Ken Tucker [MVP] - 24 Oct 2004 15:54 GMT
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

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

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
Richard L Rosenheim - 24 Oct 2004 17:11 GMT
Thanks.

Richard

> Hi,
>
[quoted text clipped - 27 lines]
>
> request =

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

> response = request.GetResponse()
>
[quoted text clipped - 45 lines]
>
> TIA

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.