Results 1 to 4 of 4

Thread: Does a file exist using the URL

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Does a file exist using the URL

    Is there anyway in .net to find out if a file exists using its URL as opposed to its physical path ?

  2. #2
    Addicted Member rdove's Avatar
    Join Date
    Dec 2002
    Location
    Indianapolis
    Posts
    251
    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
    ~Ryan





    Have I helped you? Please Rate my posts.

  3. #3
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    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?
    Magiaus

    If I helped give me some points.

  4. #4

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    That's exactly the case.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width