我試圖下載的文件是這樣的:Web客戶端DownloadFileCompleted獲取文件名
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問題
http://msdn.microsoft.com/en-us/library/17sde2xt(v=VS.100).aspx – Leri
也許全球變量 – VladL
我知道如何使用事件=)我不知道如何使用我的事件而不是DownloadFileCompleted與我的eventArgs – user1644087