check if a file exists on a web server

  • Thread starter Thread starter Jane
  • Start date Start date
J

Jane

Hello,

I am developing a windows service application that checks
if a particular web page is on the web server. I found
there is a method called File.exists(path) to check it,
but how can I get absolute path of a web page in a windows
application rather than a web application? In a web
application, we can use Server.MapPath(mypath) to get
absolute path.

Thanks in advance.

Jane
 
This funtion should do the trick

Private Function FileExists(ByVal strFileName As String) As Boolean
Dim FileFound As String

On Error GoTo 0
FileFound = Dir(strFileName)
If Len(FileFound) = 0 Then
FileExists = False
Else
FileExists = True
End If
End Function

HTH

Russ
 
I don't know the actual source code to use right off hand (too lazy to try
it out :-) However, check out the HttpWebRequest class. I've seen this
class used in other examples to test for the existence of a web page given a
URL to test (e.g. http://www.mydomain.com/somefile.html).
 
Back
Top