标题:如何使用ProgressBar来显示下载数据的进度?请指教!
只看楼主
caijiawei
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:162
专家分:101
注 册:2008-10-7
结帖率:82.14%
已结贴  问题点数:20 回复次数:2 
如何使用ProgressBar来显示下载数据的进度?请指教!
         public override bool FetchArticles()
         {
            WebClient myClient = new WebClient();
            XmlDocument myXml = new XmlDocument();
            string filePath = "temp.rss";
            try
            {
                if (this.article == null)
                {
                    this.article = new Dictionary<string, Article>();
                }
                Article.Clear();
                //获取RSS文件
                myClient.DownloadFile(Url, filePath);
               
                myXml.Load(filePath);
                //获取父节点下的子节点,定位channel节点
                XmlNode channal = myXml.DocumentElement.FirstChild;
                foreach (XmlNode node in channal)
                {
                    if (node.Name == "item")
                    {
                        Article atcl = new Article();
                        foreach (XmlNode subName in node.ChildNodes)
                        {
                            switch (subName.Name)
                            {
                                case "title":
                                    atcl.Title = subName.InnerText;
                                    break;
                                case "link":
                                    atcl.Url = subName.InnerText;
                                    break;
                            }
                        }
                        Article.Add(atcl.Title, atcl);

                    }
                }
                Clicks++;
                return true;
            }
            catch (Exception em)
            {

                Console.WriteLine(em.ToString());
                return false;
            }

        }
要从指定的Url地址上下载Rss文件到本地,
 myClient.DownloadFile(Url, filePath);
怎样才能根据DownloadFile方法的下载数据进度来显是ProgressBar空键的进度呢?
请各位指教,谢谢……
搜索更多相关主题的帖子: 指教 数据 进度 ProgressBar 
2010-02-25 22:21
caijiawei
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:162
专家分:101
注 册:2008-10-7
得分:0 
怎么没一个人回复啊?

不懂就要问,我从不感觉请教他人是一件很丢人的事!
2010-02-26 21:31
qubo1982
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:1
帖 子:367
专家分:1132
注 册:2009-3-18
得分:20 
//添加myClient的DownloadProgressChanged事件
myClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);


        void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            //这就值就是你要的百分比值
            e.ProgressPercentage
        }
2010-02-27 13:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-298123-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.179875 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved