1
我想下载之前就存在使用Net.WebClient调用文件DownloadFile礼貌地检查,看是否有文件下载
Using client As New Net.WebClient()
Try
client.DownloadFile(PDFURL, FullPDFFilePath)
然后我捕捉到了异常,并检查消息403,404,或500错误(最常见的类型为系统我们呼吁到。
Catch ex as exception
If exceptionMessage.Contains("(403)") Then 'Forbidden
LogInformation("403 returned on download for " + CRPOrderNum, "DownloadLabels")
ElseIf exceptionMessage.Contains("(404)") Then 'Not Found
LogInformation("404 returned on download for " + CRPOrderNum, "DownloadLabels")
else
'blah blah
end if
finally
end try
有一种礼貌的方式,我可以要求的文件,而不是调用DownloadFile和处理异常?
提前致谢。