> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/io/directorycreate.md).

# DirectoryCreate

Creates a directory

## Method Signature

```
DirectoryCreate(path=[string], createPath=[boolean], ignoreExists=[boolean], mode=[string])
```

### Arguments

| Argument       | Type      | Required | Description                                                                | Default |
| -------------- | --------- | -------- | -------------------------------------------------------------------------- | ------- |
| `path`         | `string`  | `true`   | The directory path to create                                               |         |
| `createPath`   | `boolean` | `false`  | \[true] Whether to create all paths necessary to create the directory path | `true`  |
| `ignoreExists` | `boolean` | `false`  | \[false] Whether to ignore if a directory already exists                   | `false` |
| `mode`         | `string`  | `false`  | When provided will attempt to set the posix permissions on the directory   |         |

## Examples

### Script Syntax

Checking if a directory called 'icons' exists and then creating the directory if it does not exist.

[Run Example](https://try.boxlang.io/?code=eJzLTNNQUEzJLEpNLskvqnStyCwuKdZQSK0oSMxLCUgsydBQUNJPLC5OLSnWz8xN189Mzs8rVlLQBMNqLk64Tuei1MSSVKBqLIqtuWq5AEzXIoU%3D)

```java
if( !directoryExists( expandPath( "/assets/img/icons" ) ) ) {
	directoryCreate( "assets/img/icons" );
}

```

Result: The directory 'icons' will be created under the img folder.

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJw9ijEKhTAQBXtP8bCKIOQAv%2FwX%2BIUXWMxiFvKTsFlRb68o2EwxM95jitKwSUqYlckYlZSzIYjybEUPbJEzcjHwLs26N3zv3126Ug4%2FsujQy58Wbn6tqVBoPYYRpis%2FxPDpTmR7KFI%3D)

```java
// This will create parent directory when not exist
directoryCreate( expandPath( "images/uploads" ), true, true );

```

## Related

* [ContractPath](/boxlang-language/reference/built-in-functions/io/contractpath.md)
* [CreateTempDirectory](/boxlang-language/reference/built-in-functions/io/createtempdirectory.md)
* [CreateTempFile](/boxlang-language/reference/built-in-functions/io/createtempfile.md)
* [DirectoryCopy](/boxlang-language/reference/built-in-functions/io/directorycopy.md)
* [DirectoryDelete](/boxlang-language/reference/built-in-functions/io/directorydelete.md)
* [DirectoryExists](/boxlang-language/reference/built-in-functions/io/directoryexists.md)
* [DirectoryList](/boxlang-language/reference/built-in-functions/io/directorylist.md)
* [DirectoryMove](/boxlang-language/reference/built-in-functions/io/directorymove.md)
* [DirectoryRename](/boxlang-language/reference/built-in-functions/io/directoryrename.md)
* [ExpandPath](/boxlang-language/reference/built-in-functions/io/expandpath.md)
* [FileAppend](/boxlang-language/reference/built-in-functions/io/fileappend.md)
* [FileClose](/boxlang-language/reference/built-in-functions/io/fileclose.md)
* [FileCopy](/boxlang-language/reference/built-in-functions/io/filecopy.md)
* [FileDelete](/boxlang-language/reference/built-in-functions/io/filedelete.md)
* [FileExists](/boxlang-language/reference/built-in-functions/io/fileexists.md)
* [FileGetMimeType](/boxlang-language/reference/built-in-functions/io/filegetmimetype.md)
* [FileInfo](/boxlang-language/reference/built-in-functions/io/fileinfo.md)
* [FileIsEOF](/boxlang-language/reference/built-in-functions/io/fileiseof.md)
* [FileMove](/boxlang-language/reference/built-in-functions/io/filemove.md)
* [FileOpen](/boxlang-language/reference/built-in-functions/io/fileopen.md)
* [FileRead](/boxlang-language/reference/built-in-functions/io/fileread.md)
* [FileReadBinary](/boxlang-language/reference/built-in-functions/io/filereadbinary.md)
* [FileReadLine](/boxlang-language/reference/built-in-functions/io/filereadline.md)
* [FileSeek](/boxlang-language/reference/built-in-functions/io/fileseek.md)
* [FileSetAccessMode](/boxlang-language/reference/built-in-functions/io/filesetaccessmode.md)
* [FileSetAttribute](/boxlang-language/reference/built-in-functions/io/filesetattribute.md)
* [FileSetLastModified](/boxlang-language/reference/built-in-functions/io/filesetlastmodified.md)
* [FileSkipBytes](/boxlang-language/reference/built-in-functions/io/fileskipbytes.md)
* [FileWrite](/boxlang-language/reference/built-in-functions/io/filewrite.md)
* [FileWriteLine](/boxlang-language/reference/built-in-functions/io/filewriteline.md)
* [GetCanonicalPath](/boxlang-language/reference/built-in-functions/io/getcanonicalpath.md)
* [GetDirectoryFromPath](/boxlang-language/reference/built-in-functions/io/getdirectoryfrompath.md)
* [GetFileInfo](/boxlang-language/reference/built-in-functions/io/getfileinfo.md)
* [getTempFile](/boxlang-language/reference/built-in-functions/io/gettempfile.md)
* [PropertyFile](/boxlang-language/reference/built-in-functions/io/propertyfile.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/io/directorycreate.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
