?
Solved

jscript fileexists not working

Posted on 2005-03-22
3
Medium Priority
?
317 Views
Last Modified: 2012-05-05
I've tried every conceivable file, both absolute and relative paths, in the same folder and in the root directory, and it simply doesn't work. It always says not found. Any suggestions?

var fs = new ActiveXObject("Scripting.FileSystemObject");

if(fs.FileExists("test.asp") == true)
{
      Response.Write("File exists.")
}
else
{
      Response.Write("File does not exist.")
}
0
Comment
Question by:arabiafish
[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
3 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 13606595
Is this client or server code?  I am assuming the file is on the server, right?
0
 
LVL 14

Accepted Solution

by:
kiddanger earned 2000 total points
ID: 13607454
Try this instead...

var fs = new ActiveXObject("Scripting.FileSystemObject");

if(fs.FileExists(Server.MapPath("test.asp")) == true) {
  Response.Write("File exists.")
  } else {
  Response.Write("File does not exist.")
  }

Server.MapPath returns the physical path to the file.  Without it, you would have to put the physical path.  If you just put the file when using FSO, it first looks at the path of the ASP processor, which is usually %systemroot%\system32.

HTH...
0
 
LVL 14

Expert Comment

by:kiddanger
ID: 13636520
Thank you arabiafish.  (O:=
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

777 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