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