2

我想从服务器下载文件并显示加载进度。我该怎么做?

下载我用这个:

HttpClient client = new HttpClient();
Stream response = await client.GetStreamAsync(url);

但我不知道如何获取下载文件的大小,也不知道下载了多少 感谢您的帮助

4

1 回答 1

1
HttpClient client = new HttpClient();

HttpResponseMessage response = await client.GetAsync(url);

响应对象中有StatusCode属性,你可以分析这个属性是OK还是PartialContent。您还可以观看以下链接了解更多详情: http ://social.msdn.microsoft.com/Forums/en/winappswithcsharp/thread/f27c385a-e783-4062-a0b8-e21bf1704f95

http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh781241.aspx

于 2012-09-08T18:05:41.643 回答