Whatever message this page gives is out now! Go check it out!
directoryCreate(String path [, boolean createPath [, boolean ignoreExists]])
| Parameter | Type | Default | Description |
path | Absolute path of the directory to be created. Alternatively, you can specify IP address, as in the following example: DirectoryCreate("//12.3.123.123/c_drive/test"); | ||
| createPath | boolean | true | If true, creates all intermediate/parent directories as needed. If false, throws an error when the parent directory does not exist. |
| ignoreExists | boolean | false | If true, silently succeeds if the directory already exists. If false, throws an error when the directory already exists. |
<cfscript>
testPath = getTempDirectory() & "myNewDir";
// Create directory with named parameters
directoryCreate(path=testPath, createPath=true, ignoreExists=false);
writeOutput("Directory created: " & directoryExists(testPath));
</cfscript>
<cfscript>
testPath = getTempDirectory() & "myNewDir";
// Create directory with named parameters
directoryCreate(path=testPath, createPath=true, ignoreExists=false);
writeOutput("Directory created: " & directoryExists(testPath));
</cfscript>
<cfscript>
basePath = getTempDirectory() & "nonExistentParent";
testPath = basePath & "/missing/child";
// Try to create without auto-creating parent directories — should throw error
try {
directoryCreate(path=testPath, createPath=false);
writeOutput("UNEXPECTED: No error thrown");
} catch (any e) {
writeOutput("Error caught: " & e.message);
}
</cfscript>