抖音开放平台Logo
开发者文档
控制台

FileSystemManager.rmdirSync
收藏
我的收藏

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

删除目录,开发者只能删除 用户目录(ttfile://user) 下的目录。

前提条件
业务背景
使用限制
注意事项
开发者只能删除 ttfile://user 下的目录
相关教程

语法

FileSystemManager.rmdirSync(dirPath, recursive)

参数说明

dirPath

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

recursive

类型默认值必填说明最低支持版本
boolean
是否递归删除目录下的文件
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
21103directory not empty
1.15.0
21105operation not permitted, $apiName $filePath
1.15.0
20000params $paramName is required
1.15.0
20000params $paramName type is not $paramType type
1.15.0
20000$paramName is invalid
1.15.0
21104remove path
小游戏框架内部错误,有需要请创建工单咨询
1.15.0
20000internal error
小游戏框架内部错误,有需要请创建工单咨询
1.15.0

代码示例

const fileSystemManager = tt.getFileSystemManager(); // 必须以 "ttfile://user" 开头 const exmaplePath = "ttfile://user/example-dir"; try { fileSystemManager.mkdirSync(exmaplePath); console.log("成功"); } catch (err) { console.log("失败", err); } try { fileSystemManager.rmdirSync(exmaplePath); console.log("成功"); } catch (err) { console.log("失败", err); }