<!--
{
  "availability" : [
    "iOS: 14.0.0 - 16.0.0",
    "iPadOS: 14.0.0 - 16.0.0",
    "macCatalyst: 14.0.0 - 16.0.0",
    "macOS: 11.0.0 - 13.0.0",
    "tvOS: 14.0.0 - 16.0.0",
    "watchOS: 7.0.0 - 9.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URL/init(_:isDirectory:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation3URLV_11isDirectoryACSg6System8FilePathV_Sbtcfc"
  },
  "title" : "init(_:isDirectory:)"
}
-->

# init(_:isDirectory:)

Creates a file URL that references the local file or directory at the file path you specify.

```
init?(_ path: FilePath, isDirectory: Bool)
```

## Parameters

`path`

The location in the file system.

`isDirectory`

A Boolean value that indicates whether the location is a directory.

## Discussion

> Note:
> This method avoids file system I/O to determine if the path is to a directory. When you know that information, prefer this method to initializers without the parameter.

---

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)