Solved

VBScript&ASP: want to check the existence of a file on the server !

Posted on 1998-09-04
2
153 Views
Last Modified: 2010-04-30
Hi.

I have a NT server with IIS4 etc.
I build a web site that use ONLY html, vbscript, asp.
The website is called "Website"
The directory is: "c:\InetPub\wwwroot\Website"

The actual page is "page.asp"

I want to display in the returned file ("page.asp") when the client("slave") asks for "page.asp" to the server ("master") a link only if a specified file is present on the server in "c:\InetPub\wwwroot\Website"
This page is called "present.asp"

If this page exits by a click on this link you'll jump to it
If this page doesn't exist you'll jump to "ouch.asp"

Please ask for more infos if i'm not understandable.

Thanx

A+rno
0
Comment
Question by:arnaudg
2 Comments
 
LVL 1

Accepted Solution

by:
soeding earned 50 total points
ID: 1433052
arnaudg,
put this into "page.asp":

<%
On Error Resume Next

' See if present.asp has any content:
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(Server.MapPath("/PathFromTheRoot") + "\present.asp")
txt = ""
txt = ts.ReadLine
ts.Close

' Create Link:
If txt = "" Then
  Response.Write "<a href='ouch.asp'>myLink</a>"
Else
  Response.Write "<a href='present.asp'>myLink</a>"
End If
%>

Regards
0
 
LVL 1

Author Comment

by:arnaudg
ID: 1433053
Thanx for your good answer.

Just one question more.
I tried to put your script as a function.
Function testfile()
.
End Function

And put a onclick="testfile()" in a <A></A> tag.
It doesn't work.

Could you tell me why ?

Thanx again.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now