<!--
{
  "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/fileExists(atPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileManager(im)fileExistsAtPath:"
  },
  "title" : "fileExists(atPath:)"
}
-->

# fileExists(atPath:)

Returns a Boolean value that indicates whether a file or directory exists at a specified path.

```
func fileExists(atPath path: String) -> Bool
```

## Parameters

`path`

The path of the file or directory. If `path` begins with a tilde (`~`), it must first be expanded with [`expandingTildeInPath`](/documentation/Foundation/NSString/expandingTildeInPath); otherwise, this method returns <doc://com.apple.documentation/documentation/Swift/false>.

    App Sandbox does not restrict which path values may be passed to this parameter.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if a file at the specified path exists, or <doc://com.apple.documentation/documentation/Swift/false> if the file does not exist or its existence could not be determined.

## Discussion

If the file at `path` is inaccessible to your app, perhaps because one or more parent directories are inaccessible, this method returns <doc://com.apple.documentation/documentation/Swift/false>. If the final element in `path` specifies a symbolic link, this method traverses the link and returns <doc://com.apple.documentation/documentation/Swift/true> or <doc://com.apple.documentation/documentation/Swift/false> based on the existence of the file at the link destination.

> Note:
> Attempting to predicate behavior based on the current state of the file system or a particular file on the file system is not recommended. Doing so can cause odd behavior or race conditions. It’s far better to attempt an operation (such as loading a file or creating a directory), check for errors, and handle those errors gracefully than it is to try to figure out ahead of time whether the operation will succeed. For more information on file-system race conditions, see [Race Conditions and Secure File Operations](https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585) in [Secure Coding Guide](https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Introduction.html#//apple_ref/doc/uid/TP40002415).

## See Also

[`checkResourceIsReachableAndReturnError(_:)`](/documentation/Foundation/NSURL/checkResourceIsReachableAndReturnError(_:))

Returns whether the resource pointed to by a file URL can be reached.



---

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)