Previously, I had written two posts on how to upload files to a web server, one for the case when the size of the HTTP request is small, and the other for the case when the size of the HTTP request is large. How about the downloading of files from a web server? In this post, I shall discuss how to download files from a HTTP server via the System.Net.HttpWebRequest class.
My previous post described a method of sending a file and some data via HTTP multipart post by constructing the HTTP request with the System.IO.MemoryStream class before writing the contents to the System.Net.HttpWebRequest class. This method of sending our HTTP request will work only if we can restrict the total size of our file and data.