473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Finding Download Speed using DownloadFileAsync

Hi,

I know there isn't a specific event property for the download speed, but can
anyone tell me how to find it? I'm not sure how to write the code.

Thanks,
Jason
Jul 17 '08 #1
2 5796
On Thu, 17 Jul 2008 08:51:02 -0700, greatbarrier86
<gr************@discussions.microsoft.comwrote:
I know there isn't a specific event property for the download speed, but
can
anyone tell me how to find it? I'm not sure how to write the code.
Using WebClient.DownloadFileAsync(), I don't think there's a good way to
do it. AFAIK, the WebClient class doesn't expose the information, nor
does it expose enough information for you to calculate it.

If you do the download yourself with an i/o class like NetworkStream, you
can explicitly read the data is small chunks (e.g. 8K at a time) and then
periodically calculate the download speed yourself (data read divided by
time is speed).

Pete
Jul 17 '08 #2
Before calling the function you need to do two things:
1) Either the record the time or create and start a Stopwatch in a class
level variable (function level is you use an anonymous function for part 2)
2) Add an event handler to the DownloadProgressChanged event.
3) When the event is fired, the DownloadProgressChangedEventArgs has
BytesReceived property, you can then see either
a) how much has been downloaded and the elasped time since the last time the
event was fired for a current rate, or how much since the start of downlaod
to get an average rate for the file (less helpful to a watching user of
course).

The DownloadProgressChangedEventArgs also has the TotalBytesToReceive
property which you can use along with the speed to work out the time
remaining.

Hope this helps

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"greatbarrier86" wrote:
Hi,

I know there isn't a specific event property for the download speed, but can
anyone tell me how to find it? I'm not sure how to write the code.

Thanks,
Jason
Jul 18 '08 #3

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

Similar topics

2
by: Matthew Sims | last post by:
Is it possible to force a download without using the readfile function? My website setup consists of my server that serves the web pages plus a high-speed file server elsewhere on the internet...
4
by: D. Alvarado | last post by:
Hello, I would like to design a page that measures the user's download connection. Does anyone have an example link or script that might aid me in this task? Thanks, - Dave
12
by: chipgraphics | last post by:
:confused::confused: I have been on the quest to find a php script that can serve files for downloads and limit the speed at which the file is transfered to the user. I want a faster download...
5
by: gjzusenet | last post by:
Hello. Though Python supports threading, I think it is limited to python code - as soon as you issue a command that uses an external (C?) module, all of your python threads hang until this command...
6
by: Giovanni | last post by:
Hi Guys, Really strange problem I am experiencing... I have setup a virtual directory with Read Only permissions on an ISA/IIS server (SBS 2003). In that virt. dir., I placed 1 file...
1
by: bigpoppa | last post by:
Hey, I need a script that will limit download speed and I want it integrated into the script I am using below. The script below forces downloads and hides url paths and logs stastics of downloads and...
4
by: halimunan | last post by:
Hello all, I have a question, how do i measure the download/upload speed... as if download rate, upload rate or kbps transfer rate. i want to do my own windows application using C# to measure the...
6
by: sajjadlove | last post by:
Hi there i use from following code for download a file from ftp server but it doesn't work...... what's that problem ?!...... //FTP Class public event...
4
by: nestle | last post by:
I have DSL with a download speed of 32MB/s and an upload speed of 8MB/s(according to my ISP), and I am using a router. My upload speed is always between 8MB/s and 9MB/s(which is above the max upload...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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...
0
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...

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.