FileSystemManager.readdirSync
基础库 1.15.0 开始支持本方法,低版本需做兼容处理。
读取目录内文件列表。
语法
FileSystemManager.readdirSync(dirPath)
参数说明
dirPath
string 类型,要读取的目录路径。
返回值
指定目录下的文件名数组, 类型为 Array<string>
获取失败失败则 throw Error。
扫码体验
请使用字节宿主APP扫码
代码示例
const fileSystemManager = tt.getFileSystemManager();
try {
const files = fileSystemManager.readFileSync("ttfile://user/");
console.log("调用成功", files);
} catch (err) {
console.log("调用失败", err);
}
Bug & Tip
无
点击纠错
评价此篇文档