Is there anyway in .net to find out if a file exists using its URL as opposed to its physical path ?
Printable View
Is there anyway in .net to find out if a file exists using its URL as opposed to its physical path ?
I'm not sure if .NET has a better way of checkings links or a better object, but about a year ago my team was faced with a similar problem. We found an XML Object that will simulate a request to a page and return whether it was a valid link or not.
Anyway I hope this works for you:
Code:Set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objHTTP.Open "get", strURL, False
objHTTP.Send
httpStatus = objHTTP.status
If httpStatus <> "200" Then
'link was not valid
End If
What is wrong with doing a MapPath and System.IO.File.Exists(path)?
I'm just curious when and why this is inefficient or won't work. The only time I know of is if you have a client checking for a page. Is that the case?
That's exactly the case.