I use this function to check whether a remote file or website exists...
But this does will not work when checking whether a remote folder exists (it produces a 'forbidden' error with no exception thrown). Does anyone have a function/sub for this?VB Code:
Public Function CheckURLExists(ByVal site As String) As Boolean Dim Success As Boolean Dim objUrl As New System.Uri(site) Dim objWebReq As System.Net.WebRequest Dim objResp As System.Net.WebResponse objWebReq = System.Net.WebRequest.Create(objUrl) Try objResp = objWebReq.GetResponse objResp.Close() Success = True Catch ex As Exception Success = False End Try objWebReq = Nothing Return Success End Function
p.s. I have been searching MSDN for info but cant find anything.




Reply With Quote