1

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.

Vinay N
  • 249
  • 1
  • 8
  • 32

2 Answers2

2

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";
hong developer
  • 13,291
  • 4
  • 38
  • 68
0

You can use LibraryDirectoryPath to Write file in iOS

const localFile = ${RNFS.LibraryDirectoryPath}/${fileName}

M Mahmud Hasan
  • 1,303
  • 1
  • 13
  • 20