问题
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.
回答1:
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";
来源:https://stackoverflow.com/questions/57374458/why-rnfs-cant-write-file-as-a-doc-file-in-ios