Classic ASP, adding a check if file exists...

Al4ddin2
Al4ddin2 used Ask the Experts™
on
Linked with this thread

how do I add in a check to make sure the XML file exists? If it doesn't then just use a default image in the same way?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Ideally done here...

filename=Server.MapPath "/files/items.xml"

So if no path is set then it uses a default value?!

Thanks
Developer & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
<%
dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FileExists("c:\webroot\files\items.xml")=true then
  response.write("File c:\webroot\files\items.xml" exists!")
else
  response.write("File c:\webroot\files\items.xml" does not exist!")
end if
set fs=nothing
%>

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial