Railo tip: relative file paths in cfdirectory, cffile, etcetera

Railo has so many cool features that we don't all know about! I am a pretty lazy programmer, so if I can save some typing, I love it.

When writing a file to the directory of the current executing cfm template, I normally had to do something like

<cffile action="write" file="#GetDirectoryFromPath(GetCurrentTemplatePath())#somefile.txt" output="hello world" />

But with Railo, you can use relative paths:

<cffile action="write" file="somefile.txt" output="hello world" />

And that's not just with files:

<cfdirectory action="list" directory="." name="qFiles" />
<cfset x = fileRead('mylocalfile.txt') />
<cfset x = fileRead('../mylocalfile.txt') />
#fileExists('myfile.txt')#
#directoryCreate('newdirectory')#

It's so logical, and it works perfectly. +1.000 for Railo!

del.icio.us Digg StumbleUpon Facebook Technorati Fav reddit Google Bookmarks
| Viewed 3251 times

No comments yet.

(will not be published)
Leave this field empty

flocculent-atempo