---
title: "writeFileContents(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nspasteboard/writefilecontents(_:)"
---

# writeFileContents(_:)

Writes the contents of the specified file to the pasteboard.

## Declaration

```swift
func writeFileContents(_ filename: String) -> Bool
```

## Parameters

- `filename`: The name of the file to write to the pasteboard.

## Return Value

Return Value true if the data was successfully written, otherwise false.

## Discussion

Discussion Writes the contents of the file filename to the receiver and declares the data to be of type NSFileContentsPboardType and also of a type appropriate for the file’s extension (as returned by the NSCreateFileContentsPboardType function when passed the files extension), if it has one.

## See Also

### Related Documentation

- [readFileContentsType(_:toFile:)](appkit/nspasteboard/readfilecontentstype(_:tofile:).md)

### Writing data (macOS 10.5 and earlier)

- [declareTypes(_:owner:)](appkit/nspasteboard/declaretypes(_:owner:).md)
- [addTypes(_:owner:)](appkit/nspasteboard/addtypes(_:owner:).md)
- [write(_:)](appkit/nspasteboard/write(_:).md)
