print("开始")
    
    --检查文件是否存在
    local path = "ABC.txt"
    local fileExist = cc.FileUtils:getInstance():isFileExist(path)
    if not fileExist then print("文件 "..path.." 不存在") return end

    --读取文件
    local content = cc.FileUtils:getInstance():getStringFromFile(path)
    dump(content)
    if content == "" then print("文件为空") return end
        

 

cocoslua的FileUtils使用比较特化,主要有UserDefault写xml,RenderTexture保存图片信息,

使用方式参考:https://blog.csdn.net/chinahaerbin/article/details/39586053

 

普通文本操作,比如txt等,使用普通lua文件IO:

使用方式参考lua教程:https://www.runoob.com/lua/lua-file-io.html

相关文章:

  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-11
  • 2022-12-23
  • 2021-07-20
  • 2022-01-12
  • 2022-12-23
  • 2021-12-08
  • 2021-09-02
相关资源
相似解决方案