<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileWrapper/write(toFile:atomically:updateFilenames:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileWrapper(im)writeToFile:atomically:updateFilenames:"
  },
  "title" : "write(toFile:atomically:updateFilenames:)"
}
-->

# write(toFile:atomically:updateFilenames:)

Writes a file wrapper’s contents to a given file-system node.

```
func write(toFile path: String, atomically atomicFlag: Bool, updateFilenames updateFilenamesFlag: Bool) -> Bool
```

## Parameters

`path`

Pathname of the file-system node to which the receiver’s contents are written.

`atomicFlag`

<doc://com.apple.documentation/documentation/Swift/true> to write the file safely so that:

- An existing file is not overwritten
- The method fails if the file cannot be written in its entirety

    <doc://com.apple.documentation/documentation/Swift/false>     to overwrite an existing file and ignore incomplete writes.

`updateFilenamesFlag`

<doc://com.apple.documentation/documentation/Swift/true> to update the receiver’s filenames (its filename and—for directory file wrappers—the filenames of its sub–file wrappers) be changed to the filenames of the corresponding nodes in the file system, after a successful write operation. Use this in Save or Save As operations.

    <doc://com.apple.documentation/documentation/Swift/false>     to specify that the receiver’s filenames not be updated. Use this in Save To operations.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> when the write operation is successful, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

Beginning with OS X v10.6, the preferred method of referring to files is with a `file://` URL. Therefore, this method has been deprecated in favor of [`write(to:options:originalContentsURL:)`](/documentation/Foundation/FileWrapper/write(to:options:originalContentsURL:)).

## See Also

[`filename`](/documentation/Foundation/FileWrapper/filename)

The filename of the file wrapper object



---

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)