Reputation: 269
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.
Upvotes: 1
Views: 2086
Reputation: 1173
You can use LibraryDirectoryPath
to Write file in iOS
const localFile =
${RNFS.LibraryDirectoryPath}/${fileName}
Upvotes: 0
Reputation: 13906
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";
Upvotes: 2