473,774 Members | 2,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

show download progress

Hi there

I'm currently using WebClient.Downl oadFile 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 2137
"Loane Sharp" <lo********@hot mail.com> schrieb:
I'm currently using WebClient.Downl oadFile 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.d e/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.Downl oadFile 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.d e/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.IOEx ception' 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\ap pupdate.zip",
FileMode.Create )
m_resp.GetRespo nseStream().Beg inRead(datBuffe r, 0, pktSize, New
AsyncCallback(A ddressOf On_datRead), frmSync)

[some more code skipped]

End Sub

Shared Sub On_datRead(ByVa l res As IAsyncResult)
Dim pktBytes As Integer = m_resp.GetRespo nseStream().End Read(res)
m_fs.Write(datB uffer, 0, pktBytes)
pbrSync.Value = pbrSync.Value + pktBytes
Application.DoE vents()
If pktBytes > 0 Then
m_resp.GetRespo nseStream().Beg inRead(datBuffe r, 0, pktSize,
New AsyncCallback(A ddressOf On_datRead), frmSync)
Else:
m_fs.Close()
m_fs = Nothing
End If
End Sub

End Class

"Loane Sharp" <lo********@hot mail.com> wrote in message
news:eF******** ******@tk2msftn gp13.phx.gbl...
Hi there

I'm currently using WebClient.Downl oadFile 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.downl oadfile

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******** *******@TK2MSFT NGP10.phx.gbl.. .
"Loane Sharp" <lo********@hot mail.com> schrieb:
I'm currently using WebClient.Downl oadFile 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.d e/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 = "Downloadin g file ....."

Application.DoE vents()

request =
WebRequest.Crea te("http://www.onteorasoft ware.com/downloads/multigrids.zip" )

response = request.GetResp onse()

reader = response.GetRes ponseStream()

ProgressBar1.Ma ximum = CInt(response.C ontentLength)

ProgressBar1.Va lue = 0

total = 0

writer = File.Create("my localdata.zip")

While True

count = reader.Read(dat a, 0, 1024)

If count <= 0 Then

Exit While

End If

writer.Write(da ta, 0, count)

total += 1024

If total < ProgressBar1.Ma ximum Then ProgressBar1.Va lue = total

Application.DoE vents()

End While

reader.Close()

writer.Close()

Ken

--------------------------
"Loane Sharp" <lo********@hot mail.com> wrote in message
news:eF******** ******@tk2msftn gp13.phx.gbl...
Hi there

I'm currently using WebClient.Downl oadFile 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***@bellsout h.net> wrote in message
news:OO******** ******@TK2MSFTN GP14.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 = "Downloadin g file ....."

Application.DoE vents()

request =
WebRequest.Crea te("http://www.onteorasoft ware.com/downloads/multigrids.zip" )

response = request.GetResp onse()

reader = response.GetRes ponseStream()

ProgressBar1.Ma ximum = CInt(response.C ontentLength)

ProgressBar1.Va lue = 0

total = 0

writer = File.Create("my localdata.zip")

While True

count = reader.Read(dat a, 0, 1024)

If count <= 0 Then

Exit While

End If

writer.Write(da ta, 0, count)

total += 1024

If total < ProgressBar1.Ma ximum Then ProgressBar1.Va lue = total

Application.DoE vents()

End While

reader.Close()

writer.Close()

Ken

--------------------------
"Loane Sharp" <lo********@hot mail.com> wrote in message
news:eF******** ******@tk2msftn gp13.phx.gbl...
Hi there

I'm currently using WebClient.Downl oadFile 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
13891
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" monitor the progress in Inet_StateChanged(ByVal State ByVal Integer)
2
6179
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 the way the download transport is handled that this cannot "automatically" be done... upload progress meters exist, but not download. However, I've seen different theories on how it could be done if one knows the file size. Is anyone aware of a...
9
1999
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 newer it should start download of the update file. This wouldn't be a problem, but how can I show the progress of the upgrade file which is being downloaded? I need to show this in percents.
0
940
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 'progress' ). Thus i have a problem. This variable might be accessed by the Timer and regular download thread at the same time. If i'am using one download at the time its no problem. I can interlock it. But when i create new instance of the download class,...
0
1866
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 one,then whethere we can show the progress of each file sending to server in progress bar. so that the FTP clients can see the progress of file sending to the server. any idea how we can do this to show the progress of each file sending. if we...
2
2976
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 will come up, so i dont't know how to feed the progressbar (i believe i need to know the maximum # of files to get a representative progress bar?). Anyone has any ideas?
6
5083
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 this copying work. Is there any way? I am thinking that I can get the file size, but I don't know how to get the size copied. Thanks.
2
9549
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 link to download, he has no clue that something is going on (and it can take some time). Indeed if the cursor is over some text or some special parts of the page it will not be set to the 'progress' type.
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10267
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10046
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9915
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8939
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4014
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.