标签: c# .net winforms webclient
private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { }
我想检查这两种情况:
如果出现错误,请执行某些操作。
如果文件已成功下载,请执行某些操作。
答案 0 :(得分:2)
您可以检查AsyncCompletedEventArgs实例的Error和Cancelled属性:
AsyncCompletedEventArgs
Error
Cancelled
if (e.Error != null) { // there was an error, do something } else if (!e.Cancelled) { // file was downloaded fine and completed, do something }