I have the following code, and it is working correctly except writing out the status of the download.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static void clear()
{
Thread.Sleep(1500);
Console.SetCursorPosition(0, 0);
}
static void Main(string[] args)
{
var client = new WebClient();
client.DownloadProgressChanged += (o, e) =>
{
Console.Write(e.ProgressPercentage + "% ");
clear();
};
client.DownloadFileAsync(new Uri("http://XXX"), "file");
Console.ReadKey();
}
}
}
With the code many new lines will be inserted and the status of the download will not be updated and printed out.