【发布时间】:2017-06-03 15:53:57
【问题描述】:
我有以下代码,除了写出下载状态外,它工作正常。
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();
}
}
}
该代码将插入许多新行,并且不会更新和打印下载状态。
【问题讨论】: