Quick Tip: cffile action=”append” in cfscript

So this is old news - like ColdFuison 8 old news - but I've only started to use cfscript heavily with ColdFusion 9 so I just ran into this today. If you need to append to a file in cfscript you first need to use FileOpen() to open a file object in the append mode.

fileObj = FileOpen("/path/to/myfile.txt","append");

Then you can append to the file using FileWrite():

FileWrite( fileObj, "What ever is here gets appended.");

Note that unlike the default behavior of <cffile action="append"> FileWrite() does not append a newline character to text written to file.

Appending to a file isn't documented on the FileWrite() documentation for either ColdFusion 8 or ColdFuison 9, and the documentation does not list FileOpen() in the See Also section, so this took me a lot longer to figure out than it should have. Anyway, I hope this helps others making the transition from tag based to script based CFML.

Sam Farmer's Gravatar You should also do a fileClose when you are done: fileClose( fileObj );
# Posted By Sam Farmer | 2/1/11 4:26 PM
Nathan Mische's Gravatar Thanks Sam. FileClose() is also not documented in the FileWrite() documentation, and not shown in the FileWrite() example code, so I'm sure others will miss it as well.
# Posted By Nathan Mische | 2/2/11 8:50 PM
Cheap Juicy Couture's Gravatar If you're ready to have a baby as well as within being pregnant, you must certainly obtain coach outlet. Due to the fact these kinds of luggage supply you a variety of benefits to together by yourself plus your toddler, also they are stylish.
# Posted By Cheap Juicy Couture | 4/16/12 7:55 AM
Louis Vuitton Outlet's Gravatar Welcome to visit Louis Vuitton Outlet. We are an online stroe from Louis Vuitton USA. Louis Vuitton Outlet provide a wide selection of Louis Vuitton products, such as Louis Vuitton Handbags, Louis Vuitton Sunglasses and so on. Big discounts are available for Louis Vuitton Sale at Louis Vuitton Outlet Store. Come and take your favorite Louis Vuitton.
# Posted By Louis Vuitton Outlet | 10/18/12 11:08 PM
Cheap Polo Shirt's Gravatar Cheap Ralph Laurenare popular all over the world. Fashionable style and top quality Ralph Lauren products guaranteed. Cheap Polo Shirtsand new updated Polos and jackets are with great discount price. You will fall in love with our Ralph Lauren Online. We are confident that you will be quite satisfied with everything at Ralph Lauren Online Shop. Take Action Now!
# Posted By Cheap Polo Shirt | 10/18/12 11:14 PM
Martie's Gravatar Use FileWriteLine instead of FileWrite and you'll get the new line
# Posted By Martie | 2/9/13 5:25 PM
# Posted By greenhill33 | 6/1/13 9:05 AM
# Posted By Air Jordan | 6/19/13 10:07 AM
# Posted By Munich Shoes Sale | 7/4/13 6:53 PM
what is a dissertation paper's Gravatar ColdFusion introduced basic OO functionality with the component language construct which resembles classes in OO languages. Each component may contain any number of properties and methods.
http://www.dissertationpaper.net/ what is a dissertation paper
# Posted By what is a dissertation paper | 7/16/13 4:41 PM
family support worker Phoenix's Gravatar This can occur through the sharing of material substances the giving and receiving of care and nurture jural ties of rights and obligations; and moral and sentimental ties. Thanks.
# Posted By family support worker Phoenix | 7/31/13 8:30 PM
at home behavioral therapy's Gravatar The most common form of this family is regularly referred to in sociology as a nuclear family. A consanguineal family consists of a parent and his or her children, and other people. Thanks.
# Posted By at home behavioral therapy | 7/31/13 8:31 PM
bawefd's Gravatar swrhgsrtfswegf
# Posted By bawefd | 8/21/13 1:51 PM
Nike Dunk High Heels's Gravatar cheap nike high heels sale in online store,buy ralph lauren sneakers in http://www.polosralphlaurenoutlet.org.uk/ Polo Ralph Lauren Outlet
http://www.nikedunkheelshigh.co.uk/ Nike Dunk High Heels shop with low discount
# Posted By Nike Dunk High Heels | 9/5/13 7:51 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.