Link to home
Start Free TrialLog in
Avatar of opacons
opacons

asked on

ASP FileExists returns true when it should return false

When I use the ASP FileSystemObject.FileExist function to check for a file in a subfolder, the return value is TRUE even though the file I'm checking for is NOT present.

Strangely this seems to occur in only once place:- other parts of the code where the same function is used work correctly.

By way of further explanation, the script containing the problematic code is called via an SSI; a technique used extensively throughout the website.

I've already spent a whole frustrating day on this seemingly simple problem so I'm inclined to offer a substantial number of points for the solution.
Avatar of dinomix
dinomix

I know this may seem obvious, but, check to make sure the file is not hidden.
Avatar of opacons

ASKER

It's not hidden.

I've even deleted an existing file to see if the behaviour persists and it does.
Can you post the code please, since it only happens in that one part of the code and not everywhere there may be something else affecting the result.
Avatar of opacons

ASKER

Line 5 should return false because the file does not exist in the named folder. Instead, a "include file not found" error is displayed because of an attempt to execute line 6 rather than line 8.
/default.asp
1 <%@ Language="VBScript" %>
2 <% Option Explicit %>
3 <!-- #include virtual="/shop/inc/incfiles.asp" -->
 
/shop/inc/incfiles.asp
1 <%
2 Dim fso
3 Set fso = Server.CreateObject("Scripting.FileSystemObject")
4 %>
5 <% if fso.FileExists(Server.MapPath("/newsite/inc/modAdovbsG.asp")) then %>
6 <!--#include virtual="/newsite/inc/modAdovbsG.asp" -->
7 <% else %>
8 <!--#include virtual="/inc/modAdovbsG.asp" -->
9 <% end if %>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jarw
jarw

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial