为什么RNFS不能在iOS中将文件写为doc文件? [英] Why RNFS can't write file as a doc file in iOS?
本文介绍了为什么RNFS不能在iOS中将文件写为doc文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试打开使用 RNFS 编写的文档文件.但我无法打开该文件.当我尝试在 iOS 中使用 word application 打开文件时,出现此错误,显示无法打开文件,文件格式与文件扩展名不匹配".
I'm trying to open a doc file written using RNFS. But I'm unable to open that file. When I try to open the file using the word application in iOS , I'm getting this error showing "Can't open file, file format doesn't match the file extension".
var path = RNFS.DocumentDirectoryPath + "/test.doc";
RNFS.writeFile(
path,
"Project Details\n",
"utf8"
);
但这在安卓中运行良好.
But this is working fine in android.
推荐答案
iOS 仅提供只读的 .doc
文件.你必须使用 .docx
.
iOS only provides .doc
files for read only. You have to use .docx
.
import { Platform } from 'react-native';
var path = Platform.OS === 'ios' ? RNFS.DocumentDirectoryPath + "/test.docx" : RNFS.DocumentDirectoryPath + "/test.doc";
这篇关于为什么RNFS不能在iOS中将文件写为doc文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文