<!--- Build filename here --->
<CFSET FileName = "c:\foo.txt">
<CFIF FileExists(FileName)>
Code here
</CFIF>
Chris Lofback
Sr. Web Developer
TRX Integration
28051 US 19 N., Ste. C
Clearwater, FL 33761
www.trxi.com
-----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]
+---------------------------------------------------------------------------
---------+
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
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