---
title: "init(filePath:directoryHint:relativeTo:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/url/init(filepath:directoryhint:relativeto:)"
---

# init(filePath:directoryHint:relativeTo:)

Creates a file URL that references a path you specify as a string.

## Declaration

```swift
init(filePath path: String, directoryHint: URL.DirectoryHint = .inferFromPath, relativeTo base: URL? = nil)
```

## Parameters

- `path`: The location in the file system, as a string.
- `directoryHint`: A hint to the initializer to indicate whether the path is a directory, or to instruct the initializer to make this determination.
- `base`: A URL that provides a file system location that the path extends.

## Mentioned in

Improving performance and stability when accessing the file system

## See Also

### Creating a file URL from a string path

- [URL.DirectoryHint](foundation/url/directoryhint.md)
- [init(fileURLWithPath:)](foundation/url/init(fileurlwithpath:).md)
- [init(fileURLWithPath:isDirectory:)](foundation/url/init(fileurlwithpath:isdirectory:).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)
