check if a file exists on a web server

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
 
R

Russ Green

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
 
J

Jeff B.

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top