|
ColdFusion 9.0 Resources |
FileWriteDescriptionIf you specify a file path, writes the entire content to the specified on-disk or in-memory file. If you specify a file object, writes text or binary data to the file object. Parameters
UsageUse the following syntax to specify an in-memory file, which is not written to disk. In-memory files speed processing of transient data. ram:///filepath The filepath can include directories, for example ram:///petStore/images/poodle.jpg. Create the directories in the path before you specify the file. For more information on using in-memory files, see Optimizing transient files in the Developing ColdFusion Applications. Example<h3>FileWrite Example</h3>
<!--- This example gets the email addresses of employees, --->
<!--- creates a file object that contains the e-mail addresses, --->
<!--- read the file object, and then creates a text file with a --->
<!--- list of e-mail addresses. --->
<cfquery name="getemployees" datasource="cfdocexamples">
SELECT EMAIL
FROM Employees
</cfquery>
<cfset companymail = "">
<cfloop query = "getemployees">
<cfset companymail = companymail & #EMAIL# & ";" & " ">
</cfloop>
<cfscript>
FileWrite("mail_list", "#companymail#");
mlist = FileRead("mail_list");
FileWrite("c:\temp\mail_list.txt", "#mlist#");
</cfscript>
|