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); 
    }); 
分享
微博
QQ
微信
回复
2024-08-06 20:04:12
相关问题
HarmonyOS如何解压rawfilezip文件
79浏览 • 1回复 待解决
鸿蒙如何读取resources目录下文件
2973浏览 • 1回复 待解决
无法读取到hsp模块rawfile文件
1499浏览 • 1回复 待解决
应用如何获取应用metadata信息?
575浏览 • 1回复 待解决