Whatever message this page gives is out now! Go check it out!
FileWrite(file, data [, charset])
OR
FileWrite(file, data)Parameter | Description |
charset | The character encoding in which the file contents is encoded. The following list includes commonly used values:
|
data | Content of the file or file object to create. |
file | Name of the file object to write. Pathname of the on-disk or in-memory file to write. If not an absolute path (starting with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the getTempDirectory function. |
ram:///filepath |
<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><cfscript>
myFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "file.txt"
FileWrite(file=myFile, data="Hello World!",charset= "UTF-8")
</cfscript>