views:

62

answers:

2

Right now i use either HttpWebRequest or WebClient to download files. I would like to see how many kbytes per second i am currently downloading at. How may i do this?

+1  A: 

Here is a good project that will show you how to do this using httpwebrequest:

http://stuff.seans.com/2009/01/05/using-httpwebrequest-for-asynchronous-downloads/

Here is a good msdn article on the process:

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.begingetresponse.aspx

Here is an event you can use, if using the webclient:

http://msdn.microsoft.com/en-us/library/system.net.webclient.downloadprogresschanged.aspx

James Campbell
+1  A: 

The most easy way is to use WebClient.DownloadProgressChanged

                    using (WebClient client = new WebClient())
                    {
                        client.DownloadProgressChanged += MyCounterHandler;
                        client.DownloadFileCompleted += MyDoneHandler;
                        client.DownloadFileAsync(URI, tmpPath);
                    }
Vasiliy Borovyak