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

# contents(atPath:)

Returns the contents of the file at the specified path.

## Declaration

```swift
func contents(atPath path: String) -> Data?
```

## Parameters

- `path`: The path of the file whose contents you want.

## Return Value

Return Value An NSData object with the contents of the file. If path specifies a directory, or if some other error occurs, this method returns nil.

## See Also

### Related Documentation

- [createFile(atPath:contents:attributes:)](foundation/filemanager/createfile(atpath:contents:attributes:).md)

### Getting and comparing file contents

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