• 0

[C#] how to know the speed of your download


Question

hi

i start to start a program that download a file from the web using the WebClient

everything worked fine but......is there a way to know the speed the program is downloading and the time it need to finish

for those who don't know what WebClient is

see this code

using System.Net; // it is in the top of the class or the form in other word
~~
WebClient myWeb = new WebClient();
myWeb.DownloadFile(urlTB.Text,fileLocationTB.Text);

urlTB hold the the internet url ex: http://www.something.com/myfile.zip

fileLocationTB hold the location of the file in the disk ex: c:\download\myfile.zip

thanks in advance

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Just set up a timer to check the size of the file every 1 sec and subtract it from the previous size, this'll give you the current rate. Then use that rate and the total filesize (not sure how to find that) to find the remaining time. Might be a sucky way to do it, but I'll guarantee it'll work.

Link to comment
Share on other sites

  • 0

Yeah.. not the best of ways to implement that.. the best idea for this sort of thing is to write your own asyncrous downloader using WebRequest and Responses. Its actually fairly easy.. You could look on codeproject or something for some starters. :)

Dan

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.