> ## Documentation Index
> Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 将绝对路径转换为文件 URL

使用 `Bun.pathToFileURL()` 将绝对路径转换为 `file://` URL。

```ts theme={"theme":{"light":"github-light","dark":"dracula"}}
Bun.pathToFileURL("/path/to/file.txt");
// => "file:///path/to/file.txt"
```

***

参见 [文档 > API > 工具](/runtime/utils) 获取更多实用工具。
