User Guide

Table Of Contents
1012 Chapter 41: Managing Files on the Server
Appending a text file
You can use
cffile to append additional text to the end of a text file; for example, when you
create log files.
To append a text file:
1.
Open the writetextfileaction.cfm file.
2.
Change the value for the action attribute from write to append so that the file appears as
follows:
<html>
<head>
<title>Append a Text File</title>
</head>
<body>
<cffile action="append"
file="C:\inetpub\wwwroot\mine\message.txt"
output="Appended By: #Form.Name#">
</body>
</html>
3.
Save the file as writetextfileaction.cfm in the myapps directory under your web_root.
4.
View the file in the browser, enter values, and submit the form.
The appended information displays at the end of the text file.
Using cfdirectory
Use the cfdirectory tag to return file information from a specified directory and to create,
delete, and rename directories. When listing directory contents or deleting a directory, you can
optionally use the
recurse attribute to access or delete all subdirectories.
As with
cffile, you can disable cfdirectory processing in the ColdFusion MX Administrator.
For details on the syntax of this tag, see CFML Reference.
Returning file information
When you use the
action="list" attribute setting, cfdirectory returns a query object as
specified in the
name attribute. The name attribute is required when you use the action="list"
attribute setting. This query object contains result columns that you can reference in a
cfoutput
tag, using the value specified in the
name attribute:
name Directory entry name.
directory Directory containing the entry.
size Directory entry size.
type File type: File or Dir.
dateLastModified Date an entry was last modified.
attributes (Windows only) File attributes, if applicable.