运行时包管理器打包器测试运行器代码检查格式化指南参考博客反馈

将文件复制到另一个位置

使用 Bun.write() 将文件复制到磁盘上的另一个位置。第一个参数是_目标位置_,例如绝对路径或 BunFile 实例。第二个参数是要写入的_数据_。

TypeScript
const file = Bun.file("/path/to/original.txt");
await Bun.write("/path/to/copy.txt", file);

请参阅 Bun.write()。