detect if file exists


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: detect if file exists

  1. #1
    ljb Guest

    detect if file exists

    How do I detect if a file exists on some server using client side VBscript?
    What I want to do is open http://somwhere.com/hereIam.htm in a new browser
    window if it exists otherwise pop up a message box or goto some alternate
    location. What I have done with xml files is:

    client side vbscript

    Set xmlDoc = CreateObject("MSXML.DOMDocument")
    xmlDoc.async = False
    If xmlDoc.Load("http://somwhere.com/hereIam.xml") Then
    WScript.CreateObject("WScript.Shell").run .....

    I don't necessarily want to load the file but just detect its presence. Is
    there a better way that would work for xml, shtml or html?

    thanks



  2. #2
    ynwt Guest

    Re: detect if file exists


    What I would do is

    <script language="VBScript">
    dim objCtrl
    set objCtrl = CreateObject("InetCtls.Inet")
    result = objCtrl.OpenURL("http://www.microsoft.com/def/abc.html")
    header = objCtrl.GetHeader
    while objCtrl.StillExecuting
    wend
    if instr(header,"404") > 0 then
    document.write "not found"
    else
    document.write header
    end if
    </script>

    ynwt
    ====
    "ljb" <ljbartel@butlermfg.com> wrote:
    >How do I detect if a file exists on some server using client side VBscript?
    >What I want to do is open http://somwhere.com/hereIam.htm in a new browser
    >window if it exists otherwise pop up a message box or goto some alternate
    >location. What I have done with xml files is:
    >
    >client side vbscript
    >
    > Set xmlDoc = CreateObject("MSXML.DOMDocument")
    > xmlDoc.async = False
    > If xmlDoc.Load("http://somwhere.com/hereIam.xml") Then
    > WScript.CreateObject("WScript.Shell").run .....
    >
    >I don't necessarily want to load the file but just detect its presence.

    Is
    >there a better way that would work for xml, shtml or html?
    >
    >thanks
    >
    >



  3. #3
    ljb Guest

    Re: detect if file exists

    I like that.

    thanks



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center