Vinay N
Vinay N

Reputation: 269

Why RNFS can't write file as a doc file in iOS?

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

Answers (2)

M Mahmud Hasan
M Mahmud Hasan

Reputation: 1173

You can use LibraryDirectoryPath to Write file in iOS

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

Upvotes: 0

hong developer
hong developer

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

Related Questions