---
title: "createDirectory(atPath:attributes:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/filemanager/createdirectory(atpath:attributes:)"
---

# createDirectory(atPath:attributes:)

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

## Declaration

```swift
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

Return Value true if the operation was successful, otherwise false.

## Discussion

Discussion Because this method does not return error information, it has been deprecated as of OS X v10.5. Use createDirectory(atPath:withIntermediateDirectories:attributes:) instead.

## See Also

### Related Documentation

- [changeCurrentDirectoryPath(_:)](foundation/filemanager/changecurrentdirectorypath(_:).md)
- [createDirectory(atPath:withIntermediateDirectories:attributes:)](foundation/filemanager/createdirectory(atpath:withintermediatedirectories:attributes:).md)
- [createFile(atPath:contents:attributes:)](foundation/filemanager/createfile(atpath:contents:attributes:).md)
- [setAttributes(_:ofItemAtPath:)](foundation/filemanager/setattributes(_:ofitematpath:).md)
- [currentDirectoryPath](foundation/filemanager/currentdirectorypath.md)

### Deprecated Methods

- [changeFileAttributes(_:atPath:)](foundation/filemanager/changefileattributes(_:atpath:).md)
- [fileAttributes(atPath:traverseLink:)](foundation/filemanager/fileattributes(atpath:traverselink:).md)
- [fileSystemAttributes(atPath:)](foundation/filemanager/filesystemattributes(atpath:).md)
- [directoryContents(atPath:)](foundation/filemanager/directorycontents(atpath:).md)
- [createSymbolicLink(atPath:pathContent:)](foundation/filemanager/createsymboliclink(atpath:pathcontent:).md)
- [pathContentOfSymbolicLink(atPath:)](foundation/filemanager/pathcontentofsymboliclink(atpath:).md)
- [fileManager(_:shouldProceedAfterError:)](objectivec/nsobject-swift.class/filemanager(_:shouldproceedaftererror:).md)
- [fileManager(_:willProcessPath:)](objectivec/nsobject-swift.class/filemanager(_:willprocesspath:).md)
- [replaceItemAtURL(originalItemURL:withItemAtURL:backupItemName:options:)](foundation/filemanager/replaceitematurl(originalitemurl:withitematurl:backupitemname:options:).md)
