<!--
{
  "availability" : [
    "iOS: 2.0.0 - 2.0.0",
    "iPadOS: 2.0.0 - 2.0.0",
    "tvOS: 9.0.0 - 9.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 2.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileManager/createDirectory(atPath:attributes:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileManager(im)createDirectoryAtPath:attributes:"
  },
  "title" : "createDirectory(atPath:attributes:)"
}
-->

# createDirectory(atPath:attributes:)

Creates a directory (without contents) at a given path with given attributes.

```
func createDirectory(atPath path: String, attributes: [AnyHashable : Any] = [:]) -> Bool
```

## Parameters

`path`

The path at which to create the new directory. The directory to be created must not yet exist, but its parent directory must exist.

`attributes`

The file attributes for the new directory. The attributes you can set are owner and group numbers, file permissions, and modification date. If you specify `nil` for `attributes`, default values for these attributes are set (particularly write access for the creator and read access for others). For a list of keys you can include in this dictionary, Supporting Types. Some of the keys, such as `NSFileHFSCreatorCode` and `NSFileHFSTypeCode`, do not apply to directories.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the operation was successful, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

Because this method does not return error information, it has been deprecated as of OS X v10.5. Use [`createDirectory(atPath:withIntermediateDirectories:attributes:)`](/documentation/Foundation/FileManager/createDirectory(atPath:withIntermediateDirectories:attributes:)) instead.

## See Also

[`changeCurrentDirectoryPath(_:)`](/documentation/Foundation/FileManager/changeCurrentDirectoryPath(_:))

Changes the path of the current working directory to the specified path.

[`createDirectory(atPath:withIntermediateDirectories:attributes:)`](/documentation/Foundation/FileManager/createDirectory(atPath:withIntermediateDirectories:attributes:))

Creates a directory with given attributes at the specified path.

[`createFile(atPath:contents:attributes:)`](/documentation/Foundation/FileManager/createFile(atPath:contents:attributes:))

Creates a file with the specified content and attributes at the given location.

[`setAttributes(_:ofItemAtPath:)`](/documentation/Foundation/FileManager/setAttributes(_:ofItemAtPath:))

Sets the attributes of the specified file or directory.

[`currentDirectoryPath`](/documentation/Foundation/FileManager/currentDirectoryPath)

The path to the program’s current directory.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)