Add Comment
New CF8 File Functions Tutorial
ColdFusion Tutorial #14
This tutorial shows you some of the new ColdFusion 8 file based functions. It takes a file and appends lines to it until it reaches a size then starts again.
demo.cfm
Line 1 defines which file we want to append.Lines 2-4 do a check to see if the file exists using fileExists and if not creates it using fileWrite.
Line 5 opens the file using fileOpen in append mode and sets it to variables.fileObj that we can refer to later.
Lines 6-8 check if the file has reached 2000 bytes and starts again if it has.
Line 9 uses the fileWriteLine function to write a new line including new line characters with the current date and time and a uuid. This can be repeated as many times as needed.
Line 10 closes the file object.
Lines 12 & 13 simply read the file back in and display it.
Demo
See this code running!
Download
Download this code as a zip!
Comments
There are no comments!Click button to add a comment
Author
Sam Farmer