In one of the previous article , we demonstrated on how to download Web Content asynchronously in C# . This article will demonstrate how to do it asynchronously.
How to Download Web Content asynchronously in C# ?
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Net; namespace AbundantcodeConsoleApp { internal class Program { private static void Main(string[] args) { // How to Download Web Content asynchronously in C# ? using (WebClient webClient = new WebClient()) { try { webClient.DownloadFileAsync(new Uri("http://Abundantcode.com"), "output.html"); } catch (WebException ex) { Console.WriteLine(ex.Message); } } Console.ReadLine(); } } }
The output file is generally saved in the same folder where the exe exists.
Leave a Reply