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

故事扮演 提交于 2019-12-13 02:57:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!