I am using the WebClient.DownloadFileAsync()
method, and wanted to know how can i pass a parameter to the WebClient.DownloadFileCompleted
event (or any other event for that matter), and use it in the invoked method.
My code:
public class MyClass
{
string downloadPath = "some_path";
void DownloadFile()
{
int fileNameID = 10;
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += DoSomethingOnFinish;
Uri uri = new Uri(downloadPath + "\" + fileNameID );
webClient.DownloadFileAsync(uri,ApplicationSettings.GetBaseFilesPath +"\" + fileNameID);
}
void DoSomethingOnFinish(object sender, AsyncCompletedEventArgs e)
{
//How can i use fileNameID's value here?
}
}
How can I pass a parameter to DoSomethingOnFinish()
?