<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileManager/contentsEqual(atPath:andPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileManager(im)contentsEqualAtPath:andPath:"
  },
  "title" : "contentsEqual(atPath:andPath:)"
}
-->

# contentsEqual(atPath:andPath:)

Returns a Boolean value that indicates whether the files or directories in specified paths have the same contents.

```
func contentsEqual(atPath path1: String, andPath path2: String) -> Bool
```

## Parameters

`path1`

The path of a file or directory to compare with the contents of `path2`.

`path2`

The path of a file or directory to compare with the contents of `path1`.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if file or directory specified in `path1` has the same contents as that specified in `path2`, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

If `path1` and `path2` are directories, the contents are the list of files and subdirectories each contains—contents of subdirectories are also compared. For files, this method checks to see if they’re the same file, then compares their size, and finally compares their contents. This method does not traverse symbolic links, but compares the links themselves.

---

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)