如何显示下载进度 [英] How to display the download progress

查看:132
本文介绍了如何显示下载进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了一个从websitl下载文件的方法..但我想修改它以显示进度条上的下载进度:

I implemented a method that download a file from a websitl ..but I want to modify it to desplay the download progress on progress bar:

 


public static void DownloadFile(string URL, string FileName, out string responseFromServ, out string StatusDesc)
  {
   // Create a request for the URL. 
   WebRequest request = WebRequest.Create(URL+"/"+FileName);
   // Get the response.
   WebResponse response = request.GetResponse();
   // Display the status.
   StatusDesc = ((HttpWebResponse)response).StatusDescription;
   // Get the stream containing content returned by the server.
   Stream dataStream = response.GetResponseStream();
   // Open the stream using a StreamReader for easy access.
   StreamReader reader = new StreamReader(dataStream);
   // Read the content.
   responseFromServ = reader.ReadToEnd();
   // Clean up the streams and the response.
   reader.Close();
   response.Close();
  }

推荐答案

请查看已经有很多帮助的论坛之一这样做。 以下只是几个例子:



http://social.msdn.microsoft.com/forums/en-us/netfxcompact/thread/0E9545C2-ADA7-4270-A99B-814EBE4729A7

http://social.msdn .microsoft.com / forums / zh-cn / Vsexpressvb / thread / EBEC8300-68E5-4104-A39C-CE0E5A3B7D80

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/7e52031e-ff82- 44f3-a70b-4656189fd38a
$


希望这会有所帮助。

Please check out one of the many forums that already have help on how to do this.  Below are just a couple of examples:

http://social.msdn.microsoft.com/forums/en-us/netfxcompact/thread/0E9545C2-ADA7-4270-A99B-814EBE4729A7
http://social.msdn.microsoft.com/forums/en-us/Vsexpressvb/thread/EBEC8300-68E5-4104-A39C-CE0E5A3B7D80
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/7e52031e-ff82-44f3-a70b-4656189fd38a

Hope this helps.


这篇关于如何显示下载进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆