This post shows you How to use WebClient.DownloadFile in c#
For example
string url = "";
string fileName = "gravatar.jpg";
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
using (WebClient client = new WebClient())
{
client.Credentials = CredentialCache.DefaultNetworkCredentials;
client.DownloadFile(url, $"{path}/{filename});
}
The DownloadFile method helps you to download locally from the URI specified by in the address parameter.
Fist, You need to provide URL where the file is located.
It downloads an avatar from the URL, then saves it to desktop as gravatar.jpg file.
You can create a console application, then copy the code above in to
class Program
{
static void Main(string[] args)
{
//Enter your code here
Console.ReadLine();
}
}
and don't forget to include the namespace below.
using System.Net;