抖音开放平台Logo
开发者文档
“/”唤起搜索
控制台
  • JavaScript API
  • C# API
  • API 概览
  • 初始化
  • 基础
  • 调试工具
  • 界面
  • 渲染
  • 数据缓存
  • PlayerPrefs
  • 文件
  • 获取文件管理器
  • 文件管理器
  • 文件流式读写
  • TTFileSystemManager
  • TTFileSystemManager.AppendFile
  • TTFileSystemManager.AppendFileSync
  • TTFileSystemManage.ReadDir
  • TTFileSystemManager.ReadDirSync
  • TTFileSystemManager.Truncate
  • TTFileSystemManager.TruncateSync
  • 设备
  • 网络
  • 系统
  • 媒体
  • 支付
  • 广告
  • 位置
  • 开放能力
  • 抖音云模块
  • TTFileSystemManage.ReadDir
    收藏
    我的收藏

    TTSDK 6.2.5 及以后版本支持该能力。
    读取目录内文件列表。
    前提条件
    无
    业务背景
    无
    使用限制
    无
    注意事项
      •文件路径通过 Application.persistentDataPath 拼接。
      • Native 方案下效果与 Directory.GetFiles 一致。
    相关教程
    无

    语法

    ​
    public void ReadDir(ReadDirParam param)

    参数说明

    param 为 ReadDirParam 类型,属性如下:
    属性名
    类型
    默认值
    必填
    说明
    DirPath
    string
    无
    是
    要读取的目录路径
    ​

    回调成功

    TTReadDirResponse 类型,属性如下:
    属性名
    类型
    说明
    errMsg
    string
    "readDir:ok"
    files
    string[]
    指定目录下的文件名数组

    回调失败

    TTReadDirResponse 类型,属性如下:
    属性名
    类型
    说明
    errMsg
    string
    "readDir:fail " + 详细错误信息

    错误码

    代码示例

    ​
    var dirPath = Application.persistentDataPath; TT.GetFileSystemManager().ReadDir(new ReadDirParam { DirPath = dirPath, success = (rsp) => { Debug.Log($"ReadDir file {dirPath} succeed!, {string.Join(",",rsp.files.ToList())}"); }, fail = (rsp) => { Debug.Log($"ReadDir file {dirPath} error!, {rsp.errMsg}"); } });
    ​
    ​
    ​