FileCreate(filename [, force])
Last updated February 20, 2003
Version: 1 | Requires: ColdFusion 5 | Library: FileSysLib
Description:
This will create a new file, only if a file with the given name does not exist. Use force=true to overwrite a file that already exists
Return Values:
Returns nothing.
Example:
<cfset filename="c:\autoexec.bat">
<cfset FileCreate(filename, false)> <!--- probably won't work --->
<cfset FileCreate(filename, true)> <!--- will truncate your autoexec.bat --->
--->
Parameters:
| Name | Description | Required |
|---|---|---|
| filename | Filename to create. | Yes |
| force | Force creation (will nuke existing file). Defaults to false. | No |
Full UDF Source:
<cfscript>
/**
* Create a new file.
*
* @param filename Filename to create. (Required)
* @param force Force creation (will nuke existing file). Defaults to false. (Optional)
* @return Returns nothing.
* @author Jesse Houwing (j.houwing@student.utwente.nl)
* @version 1, February 20, 2003
*/
function FileCreate(filename){
var force = false;
var daFile = createObject('java', 'java.io.File');
if(arraylen(arguments) gte 2) force = arguments[2];
daFile.init(JavaCast('string', filename));
if(force) daFile.delete();
daFile.createNewFile();
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
10 day(s) ago
Will Belden added
longTime
15 day(s) ago
James Sleeman added
quickSort
25 day(s) ago
Ben Forta added
GetHostAddress
28 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)