473,473 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

show download progress

Hi there

I'm currently using WebClient.DownloadFile to download a file from the
server to my local disk. Is there a way to show the progress of the file
download?

Best regards
Loane
Nov 21 '05 #1
7 2121
"Loane Sharp" <lo********@hotmail.com> schrieb:
I'm currently using WebClient.DownloadFile to download a file from the
server to my local disk. Is there a way to show the progress of the file
download?


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

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2
Hi Herfried

Thanks very much.
I'm currently using WebClient.DownloadFile to download a file from the
server to my local disk. Is there a way to show the progress of the file
download?


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

Nov 21 '05 #3
Hi H

Thank you for pointing me in the right direction. I have one small question
.... Why do I get the following error message from the JIT debugger? "An
exception 'System.IO.IOException' has occurred in synchronize.exe".

My code (a bit abbreviated) is as follows ...

Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.IO
Imports System.Net

Public Class synchronize

Inherits System.Windows.Forms.Form

Shared frmSync As Form
Shared WithEvents btn As Button
Shared lblInfo As Label
Shared pbrSync As ProgressBar
Shared res_App, res_Dat, res_Cht, cdr_Fisheye, cdr_FisheyeTemp,
emp_FisheyeTemp As Integer
Shared len_App, len_Dat, len_Cht As Double
Shared datBuffer() As Byte
Const pktSize As Integer = 65536
Shared m_resp As HttpWebResponse
Shared m_fs As FileStream

Shared Sub Main()
Application.Run(New synchronize())
End Sub

Public Sub New()
frmSync = New Form()

[some other code skipped]

m_fs = New FileStream("C:\Fisheye\temp\appupdate.zip",
FileMode.Create)
m_resp.GetResponseStream().BeginRead(datBuffer, 0, pktSize, New
AsyncCallback(AddressOf On_datRead), frmSync)

[some more code skipped]

End Sub

Shared Sub On_datRead(ByVal res As IAsyncResult)
Dim pktBytes As Integer = m_resp.GetResponseStream().EndRead(res)
m_fs.Write(datBuffer, 0, pktBytes)
pbrSync.Value = pbrSync.Value + pktBytes
Application.DoEvents()
If pktBytes > 0 Then
m_resp.GetResponseStream().BeginRead(datBuffer, 0, pktSize,
New AsyncCallback(AddressOf On_datRead), frmSync)
Else:
m_fs.Close()
m_fs = Nothing
End If
End Sub

End Class

"Loane Sharp" <lo********@hotmail.com> wrote in message
news:eF**************@tk2msftngp13.phx.gbl...
Hi there

I'm currently using WebClient.DownloadFile to download a file from the
server to my local disk. Is there a way to show the progress of the file
download?

Best regards
Loane

Nov 21 '05 #4
Herfried,

I had the idea that it was impossible to use the progressbar with the
webclient.downloadfile

However you gave a link, I did not check all 1000 other links inside that.

Can you give the exact link where that is written because I am very curious
about that.

Cor
Nov 21 '05 #5
Hi H

The CLR debugger gives the following additional information on the
IOException ...

"Additional information: The process cannot access the file "appupdate.zip"
because it is being used by another process."

Hopefully this helps

Best regards
Loane

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
"Loane Sharp" <lo********@hotmail.com> schrieb:
I'm currently using WebClient.DownloadFile to download a file from the
server to my local disk. Is there a way to show the progress of the file
download?


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

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

Nov 21 '05 #6
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

--------------------------
"Loane Sharp" <lo********@hotmail.com> wrote in message
news:eF**************@tk2msftngp13.phx.gbl...
Hi there

I'm currently using WebClient.DownloadFile to download a file from the
server to my local disk. Is there a way to show the progress of the file
download?

Best regards
Loane

Nov 21 '05 #7
Hi Ken
Thanks your code worked perfectly.
Best regards
Loane
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OO**************@TK2MSFTNGP14.phx.gbl...
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

--------------------------
"Loane Sharp" <lo********@hotmail.com> wrote in message
news:eF**************@tk2msftngp13.phx.gbl...
Hi there

I'm currently using WebClient.DownloadFile to download a file from the
server to my local disk. Is there a way to show the progress of the file
download?

Best regards
Loane

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: S.W. Rasmussen | last post by:
I have tried several times to get inet.execute to download a file with the icHTTP protocol without much success so far. I execute: Inet.Execute "http://www.domain/myfolder/myfile.file", "GET"...
2
by: Julia Briggs | last post by:
Hello, I've read quite a bit of discussion on different approaches of how to create a download progress meter that can be implemented into a Web site. I understand that by the very nature of...
9
by: Martin Ho | last post by:
My application should check for new updates when user chooses this option in the menu. It should go online and check the flag and compare with current flag in the programs directory. If version is...
0
by: PiotrKolodziej | last post by:
Hi What i need to do is add the "Transfer rate" to my Downloading file thread. I tought that i can create timer ( 1 sec event ) and check the progress of download ( long variable let say...
0
by: remya1000 | last post by:
by using FTP i can send files to server using vb.net. if the file is big, then it will take some time to complete the sending process to server.or if we were sending 3-4 files to the server one by...
2
by: mcw.willart | last post by:
Hi, I use a backgroundworker to get the total size of a homeshare (as it is a bit time-consuming). Wat i would like to do, is show the progress, but at start i don't know how much files/folders...
6
by: Michael | last post by:
I need to copy a huge file (around 300Mb) from a mapped network drive to another. I have created a console application and used System.IO.File.Copy function. But I want to know the process of...
2
by: barthelemy.von.haller | last post by:
Hi all, I googled and read this group but could not find any solution to my problem. I have a page to download big excel files that we 'build' on the server side. When a user click on the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.