File Downloader Using C#

We all have used Downloader to download the file from the internet but do you know how it works. Well, in this blog, I am going to show you how they work. A Downloader first sends a GET request to the Server from where the file is to be downloaded. After sending the GET request, the Server responds with the acknowledgement. This acknowledgement is a proof that the Server has authorized the download. Also, with the acknowledgement, the Server sends the file size and the other details.
 
I have also developed a code, using C# to demonstrate a file downloader. I have used WebClient class. You can use the code, as shown below.
 
WebClient client = new WebClient();
 
Basically, WebClient can download the file in two ways. The first is called Synchronous download and the other is called Asynchronous download. If you use Synchronous download, it will use the same thread in which the UI is running. This will hang the UI until the download is complete. This is good, if you are downloading the small file but it is not useful, if you are downloading very large file.
 
I have used Asynchronous downloading method. This will create a seperate thread to download the file so that your UI will not hang while it is downloading. Using this, you can download very large file.

If you are interested in the whole code, you can follow the link given below.