2012-02-07 61 views

回答

2

您可以使用UserState做到這一點。事情是這樣的

WebClient client = new WebClient(); 
client.DownloadDataCompleted += 
     new DownloadDataCompletedEventHandler(client_DownloadDataCompleted); 

client.DownloadDataAsync(new Uri("YourURL"), "YourIdentifier"); 

處理器

static void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) 
{ 
    var calledBy = e.UserState; //This will be "YourIdentifier" 
} 

希望這對你的作品。

0

下載文件時使用webClient.DownloadFileAsync(uri,name,state)方法。 此第三個參數(狀態)將發送到您在DownloadFileCompleted事件參數的UserState屬性中。

只需通過URI或文件名那裏,你將有很好的回:)