Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1998-09-04
2
Medium Priority
?
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
soeding earned 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

715 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