Get file size before downloading using webclient

We can use the following code to get the file size in bytes of a file and show it before actually downloading the file.

System.Net.WebClient wc = new System.Net.WebClient();
wc.OpenRead("http://patrickkroft.com/mp3/Pearl.mp3");
Int64 bytes_total= Convert.ToInt64(wc.ResponseHeaders["Content-Length"])
MessageBox.Show(bytes_total.ToString() + " Bytes");

 


Ebook Download
View all
Learn
View all