我试着像这样下载文件:
WebClient _downloadClient = new WebClient();
_downloadClient.DownloadFileCompleted += DownloadFileCompleted;
_downloadClient.DownloadFileAsync(current.url, _filename);
// ...
Run Code Online (Sandbox Code Playgroud)
下载后我需要用下载文件启动另一个进程,我尝试使用DownloadFileCompleted 事件.
void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
if (e.Error != null)
{
throw e.Error;
}
if (!_downloadFileVersion.Any())
{
complited = true;
}
DownloadFile();
}
Run Code Online (Sandbox Code Playgroud)
但是,我无法知道下载文件的名称,AsyncCompletedEventArgs我自己做了
public class DownloadCompliteEventArgs: EventArgs
{
private string _fileName;
public string fileName
{
get
{
return _fileName;
}
set
{
_fileName = value;
}
}
public DownloadCompliteEventArgs(string name)
{
fileName = name;
}
}
Run Code Online (Sandbox Code Playgroud)
但我无法理解如何调用我的活动 DownloadFileCompleted
对不起,如果这是一个很好的问题