---
title: FileWrapper
framework: foundation
role: symbol
role_heading: Class
path: foundation/filewrapper
---

# FileWrapper

A representation of a node (a file, directory, or symbolic link) in the file system.

## Declaration

```swift
class FileWrapper
```

## Overview

Overview The FileWrapper class provides access to the attributes and contents of file system nodes. A file system node is a file, directory, or symbolic link. Instances of this class are known as file wrappers. note: Starting in macOS 10.7, FileWrapper moved from Application Kit to Foundation. As a result of this the icon, and setIcon: methods have moved to a new category of FileWrapper that remains in Application Kit. File wrappers represent a file system node as an object that can be displayed as an image (and possibly edited in place), saved to the file system, or transmitted to another application. There are three types of file wrappers: Regular-file file wrapper: Represents a regular file. Directory file wrapper: Represents a directory. Symbolic-link file wrapper: Represents a symbolic link. A file wrapper has these attributes: Filename. Name of the file system node the file wrapper represents. file-system attributes. See FileManager for information on the contents of the attributes dictionary. Regular-file contents. Applicable only to regular-file file wrappers. File wrappers. Applicable only to directory file wrappers. Destination node. Applicable only to symbolic-link file wrappers.

## Topics

### Creating File Wrappers

- [init(url:options:)](foundation/filewrapper/init(url:options:)-70161.md)
- [init(path:)](foundation/filewrapper/init(path:).md)
- [init(directoryWithFileWrappers:)](foundation/filewrapper/init(directorywithfilewrappers:).md)
- [init(regularFileWithContents:)](foundation/filewrapper/init(regularfilewithcontents:).md)
- [init(symbolicLinkWithDestination:)](foundation/filewrapper/init(symboliclinkwithdestination:).md)
- [init(symbolicLinkWithDestinationURL:)](foundation/filewrapper/init(symboliclinkwithdestinationurl:).md)
- [init(serializedRepresentation:)](foundation/filewrapper/init(serializedrepresentation:).md)

### Querying File Wrappers

- [isRegularFile](foundation/filewrapper/isregularfile.md)
- [isDirectory](foundation/filewrapper/isdirectory.md)
- [isSymbolicLink](foundation/filewrapper/issymboliclink.md)

### Accessing File-Wrapper Information

- [fileWrappers](foundation/filewrapper/filewrappers.md)
- [addFileWrapper(_:)](foundation/filewrapper/addfilewrapper(_:).md)
- [removeFileWrapper(_:)](foundation/filewrapper/removefilewrapper(_:).md)
- [addFile(withPath:)](foundation/filewrapper/addfile(withpath:).md)
- [addRegularFile(withContents:preferredFilename:)](foundation/filewrapper/addregularfile(withcontents:preferredfilename:).md)
- [addSymbolicLink(withDestination:preferredFilename:)](foundation/filewrapper/addsymboliclink(withdestination:preferredfilename:).md)
- [keyForChildFileWrapper(_:)](foundation/filewrapper/keyforchildfilewrapper(_:).md)
- [symbolicLinkDestination()](foundation/filewrapper/symboliclinkdestination().md)
- [symbolicLinkDestinationURL](foundation/filewrapper/symboliclinkdestinationurl.md)

### Updating File Wrappers

- [needsToBeUpdated(fromPath:)](foundation/filewrapper/needstobeupdated(frompath:).md)
- [matchesContents(of:)](foundation/filewrapper/matchescontents(of:).md)
- [update(fromPath:)](foundation/filewrapper/update(frompath:).md)
- [read(from:options:)](foundation/filewrapper/read(from:options:).md)

### Serializing

- [serializedRepresentation](foundation/filewrapper/serializedrepresentation.md)

### Accessing Files

- [filename](foundation/filewrapper/filename.md)
- [preferredFilename](foundation/filewrapper/preferredfilename.md)
- [fileAttributes](foundation/filewrapper/fileattributes.md)
- [regularFileContents](foundation/filewrapper/regularfilecontents.md)

### Writing Files

- [write(toFile:atomically:updateFilenames:)](foundation/filewrapper/write(tofile:atomically:updatefilenames:).md)
- [write(to:options:originalContentsURL:)](foundation/filewrapper/write(to:options:originalcontentsurl:).md)

### Working with Icons

- [icon](foundation/filewrapper/icon.md)

### Constants

- [FileWrapper.ReadingOptions](foundation/filewrapper/readingoptions.md)
- [FileWrapper.WritingOptions](foundation/filewrapper/writingoptions.md)

### Initializers

- [init(URL:options:)](foundation/filewrapper/init(url:options:)-6g2yr.md)
- [init(coder:)](foundation/filewrapper/init(coder:).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)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Managed file access

- [FileHandle](foundation/filehandle.md)
- [NSFileSecurity](foundation/nsfilesecurity.md)
- [NSFileVersion](foundation/nsfileversion.md)
