Hi, all

I am downloading a file using webclient class in C#. Can I calculate the downloading speed using any custom PerformanceCounter.Can any one help me.
Thanks in advance..

Recommended Answers

All 2 Replies

I've searched how can you detect your speed and I got this piece of code

System.Net.WebClient wc = new System.Net.WebClient();
            DateTime dt1 = DateTime.Now;
            byte[] data = wc.DownloadData("http://google.com");
            DateTime dt2 = DateTime.Now;
            return (data.Length * 8) / (dt2 - dt1).TotalSeconds;
commented: an avid helper. Good work! +2

I've searched how can you detect your speed and I got this piece of code

System.Net.WebClient wc = new System.Net.WebClient();
            DateTime dt1 = DateTime.Now;
            byte[] data = wc.DownloadData("http://google.com");
            DateTime dt2 = DateTime.Now;
            return (data.Length * 8) / (dt2 - dt1).TotalSeconds;

Thanks .Its a good idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.