In this article I will explain with an example, how to download file from URL in Console (Command) Application using C# and VB.Net.
First, the File will be downloaded from the URL using WebClient class and then will be saved in a Folder (Directory) using C# and VB.Net.
File URL
The following file will be used in this article.
Welcome to ASPSnippets!
You will need to import the following namespace.
using System.Net;
Imports System.Net
Downloading File from URL
Inside the Main method, the file is downloaded from the URL using DownloadFile method of the WebClient class.
DownloadFile method
It accepts the following two parameters:
address – The URL of the file to be downloaded.
fileName – Path of the Folder (Directory) where the file will be downloaded.
static void Main(string[] args)
    ServicePointManager.Expect100Continue = true;
    ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
    WebClient webClient = new WebClient();
    webClient.DownloadFile("", @"D:\Files\ReadMe.txt");
Sub Main()
    ServicePointManager.Expect100Continue = True
    ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)
    Dim webClient As WebClient = New WebClient()
    webClient.DownloadFile("", "D:\Files\ReadMe.txt")
End Sub
Download File from URL in Console Application using C# and VB.Net