How about:

FileExists(file)

</rob>

-----Original Message-----
From: phumes1 [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 04, 2002 10:19 AM
To: CF-Talk
Subject: Check for file existence


I need to check if a file exists on the server and if so, run some code.

Whats the best way to check if the file "test.txt" exists in a directory

The below doesn't seem to work. Note that the filename can change but the
file extension (.txt) will stat the same.

<cfset FileName = ListLast(url.filename, "\")>
<cfset DirPath = Left(url.filename, Evaluate(Len(url.filename) -
len(FileName) - 1))>
<cfset TheFile = ListLast(url.filename)>
<cfset TheFolder = DirPath>

<cfparam name="dir" default="#TheFolder#">
<cfdirectory action="LIST" directory="#dir#" name="FileCheck">
<cfoutput query="FileCheck">
<cfif FileCheck.name IS "test.txt">
   <h3>Found Match</h3>
<cfelse>
   <h3>No Match</h3>
</cfif>
</cfoutput>



+---------------------------------------------------------------------------
--------+

Philip Humeniuk
[EMAIL PROTECTED]
[EMAIL PROTECTED]
+---------------------------------------------------------------------------
---------+



______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to