$web = New-Object System.Net.WebClient
$web.UseDefaultCredentials = $True
$filename = Read-Host (“要上传的文件”)
$File = dir $filename
$TargetFolder = Read-Host (“目标文档库URL,例如http://sp13/Doc1”)
$TargetFile = $TargetFolder+”/”+$File.name
$web.UploadFileAsync($TargetFile,”PUT”,($File.fullname))
if ($?) {$error[0]}
类似上面的代码,如果是同步上传,也就是$web.UploadFile($TargetFile,”PUT”,($File.fullname))的时候$?是可以得到是否出错的,但是异步时候就无法知道是否出错了,这个要怎么办?