I'm working on a YouTube Downloader, which gets sizes of all qualities available but usually that takes a very long time and sometimes it just goes like a lightning !
I wrote this Function and it's pretty good [ only sometimes as I said before ] !
Uri url = new Uri("http://example.com/document.docx");
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
response.Close();
// iSize will handle the size of the file in bytes
Int64 iSize = response.ContentLength;
.
So, Is there a faster way to do this ? ( Put on your mind that the files which will be measured are more than eight files ) .
.
In advance, thank you so much ;
That completely depends on how well-behaved the HTTP server is.
The specification says that you can send a HEAD request to get response headers like Content-Length without serving the file.
However, many servers don't do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With