Of course you don't need to download a whole file, because HTTP tells you how big the whole stream will be. But to solve the problem this way, you should not use really rudimentary
System.Net.WebClient
. You have to use
HttpWebRequest
instead:
WebClient Class (System.Net)[
^],
HttpWebRequest Class (System.Net)[
^].
Here is what I can suggest: please download the full code of my HttpDownloaded I provided in my past answer:
how to download a file from internet[
^].
This downloader allows to continue downloading of incompletely downloaded file, which apparently is based on getting the full size of a network stream from the very beginning. You will see how to do it. This is a very small piece of code, only one file; quite easy to read and understand.
See also my past answers:
how to download a file from the server in Asp.net 2.0[
^],
FTP: Download Files[
^],
How to get the data from another site[
^].
—SA