Solved

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

Posted on 1998-09-04
2
160 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 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

Industry Leaders: 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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

623 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