我正在尝试使用C#中的WebClient对象的DownloadDataAsync方法从互联网下载文件。
我还想通过使用webclient对象的DownloadProgressChanged事件来获取下载进度。
问题是,无论是BytesReceived属性还是TotalBytesToReceive属性都没有显示正确的值。当我在调试时尝试检查它们时,它们都以不可复制的方式改变。
我的代码:
WebClient client = new WebClient();
client.BaseAddress = this.DownloadUrl;
client.DownloadProgressChanged += downloadProgressDelegate;
client.DownloadDataAsync(new System.Uri(this.DownloadUrl));