<cfset variables.pathandfilename = ....set your path and filename here>

<cfif fileexists(variables.pathandfilename)>

<cfelse>

</cfif>

Hope this helps

Paul Giesenhagen
QuillDesign


> 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]
>
+---------------------------------------------------------------------------
---------+
>
>
> 
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.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

Reply via email to