【发布时间】:2012-12-17 15:27:27
【问题描述】:
我尝试下载这样的文件:
WebClient _downloadClient = new WebClient();
_downloadClient.DownloadFileCompleted += DownloadFileCompleted;
_downloadClient.DownloadFileAsync(current.url, _filename);
// ...
下载后我需要用下载文件启动另一个进程,我尝试使用DownloadFileCompleted事件。
void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
if (e.Error != null)
{
throw e.Error;
}
if (!_downloadFileVersion.Any())
{
complited = true;
}
DownloadFile();
}
但是,我不知道从AsyncCompletedEventArgs 下载的文件的名称,我自己做的
public class DownloadCompliteEventArgs: EventArgs
{
private string _fileName;
public string fileName
{
get
{
return _fileName;
}
set
{
_fileName = value;
}
}
public DownloadCompliteEventArgs(string name)
{
fileName = name;
}
}
但我不明白如何调用我的事件而不是 DownloadFileCompleted
对不起,如果是nood问题
【问题讨论】:
-
我知道如何使用事件 =) 我不知道如何使用我的事件而不是使用我的 eventArgs 下载文件完成
标签: c# event-handling webclient