异步上传时如何获取错误信息


PowerShell交流中心分类: 变量-函数-脚本-条件-循环-参数异步上传时如何获取错误信息
0
六翼天使 asked 5年 ago

$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))的时候$?是可以得到是否出错的,但是异步时候就无法知道是否出错了,这个要怎么办?

1 Answers
0
Francis answered 5年 ago

大哥,我是新手,你们怎么发的博客啊,能教教我吗