FileExists FSO

P

Poppy

If I do the following :
------------------------------------
set fsd=Server.CreateObject("Scripting.FileSystemObject")
if fsd.fileexists("C:\inetpub\wwwroot\mysite\test.doc") = true then
response.Write("EXISTS")
else
response.write "DOESNT EXIST"
end if
-------------------------------------
I get : "EXISTS"
-------------------------------------
However if I do this :
---------------------------------------
set fsd=Server.CreateObject("Scripting.FileSystemObject")
myfile = "C:\inetpub\wwwroot\mysite\test.doc"
if fsd.fileexists(myfile) = true then
response.Write("EXISTS")
else
response.write "DOESNT EXIST"
end if
 
R

Roji. P. Thomas

I failed to reproduce the issue.
have u tried with a different finename? path?
 
E

Evertjan.

Poppy wrote on 02 mrt 2004 in microsoft.public.inetserver.asp.general:
set fsd=Server.CreateObject("Scripting.FileSystemObject")
if fsd.fileexists("C:\inetpub\wwwroot\mysite\test.doc") = true then
response.Write("EXISTS")
else
response.write "DOESNT EXIST"
end if
-------------------------------------
I get : "EXISTS"
-------------------------------------
However if I do this :
---------------------------------------
set fsd=Server.CreateObject("Scripting.FileSystemObject")
myfile = "C:\inetpub\wwwroot\mysite\test.doc"
if fsd.fileexists(myfile) = true then
response.Write("EXISTS")
else
response.write "DOESNT EXIST"
end if

You must have made a mistake because my code hereunder works ok:

<%
set fsd=Server.CreateObject("Scripting.FileSystemObject")
if fsd.fileexists(server.mappath("test.asp")) then
response.Write "EXISTS"
else
response.write "DOESNT EXIST"
end if

set fsd=Server.CreateObject("Scripting.FileSystemObject")
myfile = server.mappath("test.asp")
if fsd.fileexists(myfile) then
response.Write "EXISTS"
else
response.write "DOESNT EXIST"
end if
%>

btw:

1
if x = true then
is the same as
if x then

2
response.Write("EXISTS")
is the same as
response.Write "EXISTS"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top