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

FileSystemManager.readdirSync
收藏
我的收藏

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

读取目录内文件列表。

前提条件
业务背景
使用限制
注意事项
相关教程

语法

FileSystemManager.readdirSync(dirPath)

参数说明

dirPath

类型默认值必填说明最低支持版本
string
要读取的目录路径
1.15.0

返回值

类型说明最低支持版本
array

指定目录下的文件名数组,类型为 Array<string>

1.15.0

错误码

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

代码示例

const fileSystemManager = tt.getFileSystemManager(); try { const files = fileSystemManager.readdirSync("ttfile://user/"); console.log("调用成功", files); } catch (err) { console.log("调用失败", err); }