こんばんは、DownloadProgressChangedEventHandler に基づいて独自の EventHandler を作成しようとしています。その理由は、Callback 関数に追加のパラメーター (fileName) を与えたいからです。これは私の EventHandler です:
public class MyDownloadProgressChangedEventHandler : DownloadProgressChangedEventHandler
{
public object Sender { get; set; }
public DownloadProgressChangedEventArgs E { get; set; }
public string FileName { get; set; }
public MyDownloadProgressChangedEventHandler(object sender, DownloadProgressChangedEventArgs e, string fileName)
{
this.Sender = sender;
this.E = e;
this.FileName = fileName;
}
}
そして、これは私の試みです:
WebClient client = new WebClient();
client.DownloadProgressChanged += new MyDownloadProgressChangedEventhandler(DownloadProgressChanged);
client.DownloadFileAsync(new Uri(String.Format("{0}/key={1}", srv, file)), localName);
Console.WriteLine(String.Format("Download of file {0} started.", localName));
Console.ReadLine();
しかし、VS は、MyDownloadProgressChangedEventHandler から DownloadProgressChangedEventHandler への会話は不可能であると言います。これは私が思うように可能ですか?
前もって感謝します。