resources下rawfile 的文本文件在应用开发中如何获取?

resources下rawfile 的文本文件在应用开发中如何获取?

HarmonyOS
2024-08-06 14:13:45
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
社恐的小美
getContext(this).resourceManager.getRawFileContent('test.txt', (_err, value) => { 
      let myBuffer: ArrayBufferLike = value.buffer; 
      let context = getContext(this); 
      let filePath = context.filesDir + '/111.txt'; 
      console.info('testTag-filePath:' + filePath); 
      let file = fileIo.openSync(filePath, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); 
      let writeLen = fileIo.writeSync(file.fd, myBuffer); 
      console.info('testTag-write data to file succeed and size is:' + writeLen); 
      fileIo.closeSync(file); 
    }); 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
分享
微博
QQ
微信
回复
2024-08-06 20:04:12
相关问题
HarmonyOS 如何进行文本文件读取?
1092浏览 • 1回复 待解决
HarmonyOS rawfile文件如何获取URI
845浏览 • 1回复 待解决
HarmonyOS 如何遍历resources/rawfile目录
610浏览 • 1回复 待解决
HarmonyOS RawFile文件拷贝
710浏览 • 1回复 待解决