Solved

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

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

734 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