DownloadFile への Net.WebClient 呼び出しを使用してファイルをダウンロードしようとしています
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 を呼び出して例外を処理する代わりに、ファイルを要求できる丁寧な方法はありますか?
前もって感謝します。