抖音开放平台Logo
开发者文档
“/”唤起搜索
控制台

FileSystemManager.unlinkSync
收藏
我的收藏

基础库 1.15.0 开始支持本方法,这是一个同步方法。

删除文件,只能删除 用户目录(ttfile://user)下的文件。

前提条件
业务背景
使用限制
注意事项
filePath 必须以 ttfile://user 开头
相关教程

语法

FileSystemManager.unlinkSync(filePath)

参数说明

filePath

类型默认值必填说明最低支持版本
string
要删除的文件路径,必须以 ttfile://user 开头。
1.15.0

返回值

错误码

errNoerrMsg说明最低支持版本
20001invalid param
参数错误
1.15.0
10401error stack
小游戏框架内部错误,有需要请创建工单咨询
1.15.0
21101permission denied, $apiName $dirPath
1.15.0
21102no such file or directory, $apiName $dirPath
1.15.0
21103operation not permitted, $apiName $filePath
1.15.0
20000internal error
小游戏框架内部错误,有需要请创建工单咨询
1.15.0

扫码体验

请使用字节宿主APP扫码

代码示例

开发者工具中预览

const fileSystemManager = tt.getFileSystemManager(); tt.chooseImage({ success(res) { // 保存临时文件到 用户目录 const savedFilePath = fileSystemManager.saveFileSync(res.tempFilePaths[0]); try { // 删除文件 fileSystemManager.unlinkSync(savedFilePath); console.log("删除成功"); } catch (err) { console.log("删除失败", err); } }, });