mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
19 lines
406 B
Plaintext
19 lines
406 B
Plaintext
---
|
|
title: Delete a file
|
|
sidebarTitle: Delete file
|
|
mode: center
|
|
---
|
|
|
|
The `Bun.file()` function accepts a path and returns a `BunFile` instance. Use the `.delete()` method to delete the file.
|
|
|
|
```ts
|
|
const path = "/path/to/file.txt";
|
|
const file = Bun.file(path);
|
|
|
|
await file.delete();
|
|
```
|
|
|
|
---
|
|
|
|
See [Docs > API > File I/O](/runtime/file-io#reading-files-bun-file) for complete documentation of `Bun.file()`.
|