I'm trying to download files using the Net.WebClient call to DownloadFile
Using client As New Net.WebClient()
Try
client.DownloadFile(PDFURL, FullPDFFilePath)
I then catch the exception and check the message for 403, 404, or 500 errors (the most common type for the system we are calling into.
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
Is there a polite way I can ask for the file instead of calling DownloadFile, and handling the exception ?
Thanks in advance.