WinRT:下载文件

时间:2012-09-08 15:32:17

标签: windows-runtime

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

下载时我用这个:

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

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

1 个答案:

答案 0 :(得分: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