How to determine whether a file exists in ColdFusion

FileExists() - determine whether a file exists

FileExists.cfm


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FileExists function example: how to determine whether a file exists</title>
</head>

<body>
<h2 style="color:Crimson">FileExists Function Example</h2>

<cfset File1="C:\ReadMe.txt">
<cfset File2="C:\MyFolder\ReadMe.txt">

<cfoutput>
    <b>
    File1: #File1#
    <br />
    File1 Exists?: #FileExists(File1)#
    <br /><br />
    File2: #File2#
    <br />
    File2 Exists?: #FileExists(File2)#
    </b>
</cfoutput>
</body>
</html>