---
title: FileManager
framework: foundation
role: symbol
role_heading: Class
path: foundation/filemanager
---

# FileManager

A convenient interface to the contents of the file system, and the primary means of interacting with it.

## Declaration

```swift
class FileManager
```

## Mentioned in

About Apple File System Using the file system effectively Optimizing Your App’s Data for iCloud Backup

## Overview

Overview A file manager object lets you examine the contents of the file system and make changes to it. The FileManager class provides convenient access to a shared file manager object that is suitable for most types of file-related manipulations. A file manager object is typically your primary mode of interaction with the file system. You use it to locate, create, copy, and move files and directories. You also use it to get information about a file or directory or change some of its attributes. When specifying the location of files, you can use either NSURL or NSString objects. The use of the NSURL class is generally preferred for specifying file-system items because URLs can convert path information to a more efficient representation internally. You can also obtain a bookmark from an NSURL object, which is similar to an alias and offers a more sure way of locating the file or directory later. If you are moving, copying, linking, or removing files or directories, you can use a delegate in conjunction with a file manager object to manage those operations. The delegate’s role is to affirm the operation and to decide whether to proceed when errors occur. In macOS 10.7 and later, the delegate must conform to the FileManagerDelegate protocol. In iOS 5.0 and later and in macOS 10.7 and later, FileManager includes methods for managing items stored in iCloud. Files and directories tagged for cloud storage are synced to iCloud so that they can be made available to the user’s iOS devices and Macintosh computers. Changes to an item in one location are propagated to all other locations to ensure the items stay in sync. Sync control A package is a directory that the system presents as a single file to the person using the device. Apps with documents that contain multiple files can use packages to manage contents like media assets. In iOS 26 and macOS 26 and later, FileManager introduces methods for controlling how a file provider syncs these items. By pausing sync when your app opens a package and resuming when it closes, your app can prevent the file provider from changing the contents of the package in unexpected ways, which potentially leaves the document in an inconsistent state. You can also use this pause and resume API on regular “flat” files. Threading considerations The methods of the shared FileManager object can be called from multiple threads safely. However, if you use a delegate to receive notifications about the status of move, copy, remove, and link operations, you should create a unique instance of the file manager object, assign your delegate to that object, and use that file manager to initiate your operations.

## Topics

### Creating a file manager

- [init(authorization:)](foundation/filemanager/init(authorization:).md)
- [default](foundation/filemanager/default.md)

### Accessing user directories

- [homeDirectoryForCurrentUser](foundation/filemanager/homedirectoryforcurrentuser.md)
- [NSHomeDirectory()](foundation/nshomedirectory().md)
- [NSUserName()](foundation/nsusername().md)
- [NSFullUserName()](foundation/nsfullusername().md)
- [homeDirectory(forUser:)](foundation/filemanager/homedirectory(foruser:).md)
- [NSHomeDirectoryForUser(_:)](foundation/nshomedirectoryforuser(_:).md)
- [temporaryDirectory](foundation/filemanager/temporarydirectory.md)
- [NSTemporaryDirectory()](foundation/nstemporarydirectory().md)

### Locating system directories

- [url(for:in:appropriateFor:create:)](foundation/filemanager/url(for:in:appropriatefor:create:).md)
- [urls(for:in:)](foundation/filemanager/urls(for:in:).md)
- [NSSearchPathForDirectoriesInDomains(_:_:_:)](foundation/nssearchpathfordirectoriesindomains(_:_:_:).md)
- [NSOpenStepRootDirectory()](foundation/nsopensteprootdirectory().md)

### Locating application group container directories

- [containerURL(forSecurityApplicationGroupIdentifier:)](foundation/filemanager/containerurl(forsecurityapplicationgroupidentifier:).md)
- [App Groups Entitlement](bundleresources/entitlements/com.apple.security.application-groups.md)

### Discovering directory contents

- [contentsOfDirectory(at:includingPropertiesForKeys:options:)](foundation/filemanager/contentsofdirectory(at:includingpropertiesforkeys:options:).md)
- [contentsOfDirectory(atPath:)](foundation/filemanager/contentsofdirectory(atpath:).md)
- [enumerator(at:includingPropertiesForKeys:options:errorHandler:)](foundation/filemanager/enumerator(at:includingpropertiesforkeys:options:errorhandler:).md)
- [enumerator(atPath:)](foundation/filemanager/enumerator(atpath:).md)
- [FileManager.DirectoryEnumerator](foundation/filemanager/directoryenumerator.md)
- [mountedVolumeURLs(includingResourceValuesForKeys:options:)](foundation/filemanager/mountedvolumeurls(includingresourcevaluesforkeys:options:).md)
- [FileManager.VolumeEnumerationOptions](foundation/filemanager/volumeenumerationoptions.md)
- [subpathsOfDirectory(atPath:)](foundation/filemanager/subpathsofdirectory(atpath:).md)
- [subpaths(atPath:)](foundation/filemanager/subpaths(atpath:).md)

### Creating and deleting items

- [createDirectory(at:withIntermediateDirectories:attributes:)](foundation/filemanager/createdirectory(at:withintermediatedirectories:attributes:).md)
- [createDirectory(atPath:withIntermediateDirectories:attributes:)](foundation/filemanager/createdirectory(atpath:withintermediatedirectories:attributes:).md)
- [createFile(atPath:contents:attributes:)](foundation/filemanager/createfile(atpath:contents:attributes:).md)
- [removeItem(at:)](foundation/filemanager/removeitem(at:).md)
- [removeItem(atPath:)](foundation/filemanager/removeitem(atpath:).md)
- [trashItem(at:resultingItemURL:)](foundation/filemanager/trashitem(at:resultingitemurl:).md)

### Replacing items

- [replaceItemAt(_:withItemAt:backupItemName:options:)](foundation/filemanager/replaceitemat(_:withitemat:backupitemname:options:).md)
- [replaceItem(at:withItemAt:backupItemName:options:resultingItemURL:)](foundation/filemanager/replaceitem(at:withitemat:backupitemname:options:resultingitemurl:).md)
- [FileManager.ItemReplacementOptions](foundation/filemanager/itemreplacementoptions.md)

### Moving and copying items

- [copyItem(at:to:)](foundation/filemanager/copyitem(at:to:).md)
- [copyItem(atPath:toPath:)](foundation/filemanager/copyitem(atpath:topath:).md)
- [moveItem(at:to:)](foundation/filemanager/moveitem(at:to:).md)
- [moveItem(atPath:toPath:)](foundation/filemanager/moveitem(atpath:topath:).md)

### Managing iCloud-based items

- [ubiquityIdentityToken](foundation/filemanager/ubiquityidentitytoken.md)
- [url(forUbiquityContainerIdentifier:)](foundation/filemanager/url(forubiquitycontaineridentifier:).md)
- [isUbiquitousItem(at:)](foundation/filemanager/isubiquitousitem(at:).md)
- [setUbiquitous(_:itemAt:destinationURL:)](foundation/filemanager/setubiquitous(_:itemat:destinationurl:).md)
- [startDownloadingUbiquitousItem(at:)](foundation/filemanager/startdownloadingubiquitousitem(at:).md)
- [evictUbiquitousItem(at:)](foundation/filemanager/evictubiquitousitem(at:).md)
- [url(forPublishingUbiquitousItemAt:expiration:)](foundation/filemanager/url(forpublishingubiquitousitemat:expiration:).md)

### Accessing file provider services

- [getFileProviderServicesForItem(at:completionHandler:)](foundation/filemanager/getfileproviderservicesforitem(at:completionhandler:).md)
- [NSFileProviderService](foundation/nsfileproviderservice.md)
- [NSFileProviderServiceName](foundation/nsfileproviderservicename.md)

### Controlling file provider synchronization

- [NSFileManagerSupportedSyncControls](foundation/nsfilemanagersupportedsynccontrols.md)
- [pauseSyncForUbiquitousItem(at:completionHandler:)](foundation/filemanager/pausesyncforubiquitousitem(at:completionhandler:).md)
- [resumeSyncForUbiquitousItem(at:with:completionHandler:)](foundation/filemanager/resumesyncforubiquitousitem(at:with:completionhandler:).md)
- [NSFileManagerResumeSyncBehavior](foundation/nsfilemanagerresumesyncbehavior.md)
- [fetchLatestRemoteVersionOfItem(at:completionHandler:)](foundation/filemanager/fetchlatestremoteversionofitem(at:completionhandler:).md)
- [NSFileVersion](foundation/nsfileversion.md)
- [uploadLocalVersionOfUbiquitousItem(at:withConflictResolutionPolicy:completionHandler:)](foundation/filemanager/uploadlocalversionofubiquitousitem(at:withconflictresolutionpolicy:completionhandler:).md)
- [NSFileManagerUploadLocalVersionConflictPolicy](foundation/nsfilemanageruploadlocalversionconflictpolicy.md)

### Creating symbolic and hard links

- [createSymbolicLink(at:withDestinationURL:)](foundation/filemanager/createsymboliclink(at:withdestinationurl:).md)
- [createSymbolicLink(atPath:withDestinationPath:)](foundation/filemanager/createsymboliclink(atpath:withdestinationpath:).md)
- [linkItem(at:to:)](foundation/filemanager/linkitem(at:to:).md)
- [linkItem(atPath:toPath:)](foundation/filemanager/linkitem(atpath:topath:).md)
- [destinationOfSymbolicLink(atPath:)](foundation/filemanager/destinationofsymboliclink(atpath:).md)

### Determining access to files

- [fileExists(atPath:)](foundation/filemanager/fileexists(atpath:).md)
- [fileExists(atPath:isDirectory:)](foundation/filemanager/fileexists(atpath:isdirectory:).md)
- [isReadableFile(atPath:)](foundation/filemanager/isreadablefile(atpath:).md)
- [isWritableFile(atPath:)](foundation/filemanager/iswritablefile(atpath:).md)
- [isExecutableFile(atPath:)](foundation/filemanager/isexecutablefile(atpath:).md)
- [isDeletableFile(atPath:)](foundation/filemanager/isdeletablefile(atpath:).md)

### Getting and setting attributes

- [componentsToDisplay(forPath:)](foundation/filemanager/componentstodisplay(forpath:).md)
- [displayName(atPath:)](foundation/filemanager/displayname(atpath:).md)
- [attributesOfItem(atPath:)](foundation/filemanager/attributesofitem(atpath:).md)
- [attributesOfFileSystem(forPath:)](foundation/filemanager/attributesoffilesystem(forpath:).md)
- [setAttributes(_:ofItemAtPath:)](foundation/filemanager/setattributes(_:ofitematpath:).md)

### Getting and comparing file contents

- [contents(atPath:)](foundation/filemanager/contents(atpath:).md)
- [contentsEqual(atPath:andPath:)](foundation/filemanager/contentsequal(atpath:andpath:).md)

### Getting the relationship between items

- [getRelationship(_:ofDirectoryAt:toItemAt:)](foundation/filemanager/getrelationship(_:ofdirectoryat:toitemat:).md)
- [getRelationship(_:of:in:toItemAt:)](foundation/filemanager/getrelationship(_:of:in:toitemat:).md)
- [FileManager.URLRelationship](foundation/filemanager/urlrelationship.md)

### Converting file paths to strings

- [fileSystemRepresentation(withPath:)](foundation/filemanager/filesystemrepresentation(withpath:).md)
- [string(withFileSystemRepresentation:length:)](foundation/filemanager/string(withfilesystemrepresentation:length:).md)

### Managing the delegate

- [delegate](foundation/filemanager/delegate.md)

### Managing the current directory

- [changeCurrentDirectoryPath(_:)](foundation/filemanager/changecurrentdirectorypath(_:).md)
- [currentDirectoryPath](foundation/filemanager/currentdirectorypath.md)

### Unmounting volumes

- [unmountVolume(at:options:completionHandler:)](foundation/filemanager/unmountvolume(at:options:completionhandler:).md)
- [FileManager.UnmountOptions](foundation/filemanager/unmountoptions.md)
- [NSFileManagerUnmountDissentingProcessIdentifierErrorKey](foundation/nsfilemanagerunmountdissentingprocessidentifiererrorkey.md)

### Working with HFS file types

- [NSFileTypeForHFSTypeCode(_:)](foundation/nsfiletypeforhfstypecode(_:).md)
- [NSHFSTypeCodeFromFileType(_:)](foundation/nshfstypecodefromfiletype(_:).md)
- [NSHFSTypeOfFile(_:)](foundation/nshfstypeoffile(_:).md)

### Determining resource fork support

- [NSFoundationVersionWithFileManagerResourceForkSupport](foundation/nsfoundationversionwithfilemanagerresourceforksupport.md)

### Working with notifications

- [NSUbiquityIdentityDidChange](foundation/nsnotification/name-swift.struct/nsubiquityidentitydidchange.md)

### Working with notification messages

- [FileManager.UbiquityIdentityDidChangeMessage](foundation/filemanager/ubiquityidentitydidchangemessage.md)

### Supporting Types

- [FileManager.DirectoryEnumerationOptions](foundation/filemanager/directoryenumerationoptions.md)
- [FileManager.SearchPathDirectory](foundation/filemanager/searchpathdirectory.md)
- [FileManager.SearchPathDomainMask](foundation/filemanager/searchpathdomainmask.md)
- [FileAttributeKey](foundation/fileattributekey.md)
- [FileAttributeType](foundation/fileattributetype.md)
- [FileProtectionType](foundation/fileprotectiontype.md)
- [URLFileProtection](foundation/urlfileprotection.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)
- [createDirectory(atPath:attributes:)](foundation/filemanager/createdirectory(atpath:attributes:).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)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### File system operations

- [Improving performance and stability when accessing the file system](foundation/improving-performance-and-stability-when-accessing-the-file-system.md)
- [Using the file system effectively](foundation/using-the-file-system-effectively.md)
- [FileManagerDelegate](foundation/filemanagerdelegate.md)
- [About Apple File System](foundation/about-apple-file-system.md)
