如何使用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空键的进度呢?
请各位指教,谢谢……