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

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
Al4ddin2Asked:
Who is Participating?
 
Scott Fell, EE MVEConnect With a Mentor DeveloperCommented:
<%
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
%>
0
 
Al4ddin2Author Commented:
Ideally done here...

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

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

Thanks
0
All Courses

From novice to tech pro — start learning today.