我的目标是从e。
获取已完成文件的文件名...
WebClient webClient = new WebClient();
webClient.UploadFileAsync(new Uri(address, "STOR", filename));
...
void WebClientUploadCompleted(object sender, UploadFileCompletedEventArgs e)
{
//How to get filename from e?
}
答案 0 :(得分:3)
UploadFileAsync
接受用户状态作为第四个参数。因此,您可以将呼叫更改为:
webClient.UploadFileAsync(new Uri(address), "STOR", filename, filename);
并在回调中检索它:
void WebClientUploadCompleted(object sender, UploadFileCompletedEventArgs e)
{
var filename = (string)e.UserState;
}