Whatever message this page gives is out now! Go check it out!

DirectoryCreate

Last update:
May 18, 2026

Description

Creates on-disk or in-memory directory.

Category

Function Syntax

directoryCreate(String path [, boolean createPath [, boolean ignoreExists]])
 

See Also

History

  • ColdFusion 2025.0.08: Added the parameters- createPath and ignoreExists
  • ColdFusion 9: Added this function

Parameters

ParameterTypeDefaultDescription
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.

Usage

Ensure that you have the required permissions to run this function.

Example

<cfscript>
          testPath = getTempDirectory() & "myNewDir";
          
          // Create directory with named parameters
          directoryCreate(path=testPath, createPath=true, ignoreExists=false);
          
          writeOutput("Directory created: " & directoryExists(testPath));
</cfscript>      
Example 2

<cfscript>
    testPath = getTempDirectory() & "myNewDir";
    // Create directory with named parameters
    directoryCreate(path=testPath, createPath=true, ignoreExists=false);
    writeOutput("Directory created: " & directoryExists(testPath));
</cfscript>
    
Example 3
<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>    

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page