I implemented some code I found elsewhere on this forum to check for the existence of a remote file.
But if I search for a remote file that I know does not exist, I get a 404 error response and the function bombs out, it does not jump to the Catch? Can anyone see what Im doing wrong?VB Code:
Public Function IsFileAvailable(ByVal FileLink As String) As Boolean Dim objUrl As New System.Uri(FileLink) Dim objWebReq As System.Net.WebRequest Dim objResp As System.Net.WebResponse objWebReq = System.Net.WebRequest.Create(objUrl) Try objResp = objWebReq.GetResponse objResp.Close() objWebReq = Nothing Return True Catch ex As Exception objWebReq = Nothing Return False End Try End Function




Reply With Quote