FileCreate(filename[, force])
Last updated February 20, 2003
Version: 1 | Requires: CF5 | 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:
/**
* 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();
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016