---
title: "init(fileURLWithPath:isDirectory:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/url/init(fileurlwithpath:isdirectory:)"
---

# init(fileURLWithPath:isDirectory:)

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

## Declaration

```swift
init(fileURLWithPath path: String, isDirectory: Bool)
```

## Parameters

- `path`: The location in the file system.
- `isDirectory`: A Boolean value that indicates whether the location is a directory.

## Discussion

Discussion If the path is an empty string, the system interprets it as “.”. 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.

## See Also

### Creating a file URL from a string path

- [init(filePath:directoryHint:relativeTo:)](foundation/url/init(filepath:directoryhint:relativeto:).md)
- [URL.DirectoryHint](foundation/url/directoryhint.md)
- [init(fileURLWithPath:)](foundation/url/init(fileurlwithpath:).md)
- [init(fileURLWithPath:relativeTo:)](foundation/url/init(fileurlwithpath:relativeto:).md)
- [init(fileURLWithPath:isDirectory:relativeTo:)](foundation/url/init(fileurlwithpath:isdirectory:relativeto:).md)
- [init(fileURLWithFileSystemRepresentation:isDirectory:relativeTo:)](foundation/url/init(fileurlwithfilesystemrepresentation:isdirectory:relativeto:).md)
- [init(fileReferenceLiteralResourceName:)](foundation/url/init(filereferenceliteralresourcename:).md)
- [init(filePath:directoryHint:)](foundation/url/init(filepath:directoryhint:).md)
