中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
resources下rawfile 的文本文件在应用开发中如何获取?
微信扫码分享
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); });