Ionic 3 Cordova文件插件为copyFile操作提供错误

时间:2018-04-01 02:50:53

标签: ionic-framework ionic3 cordova-plugins

我正在尝试使用copyFile(path, fileName, newPath, newFileName)函数将文件从一个目录复制到另一个目录。它给出了{"code":13, "message":"input is not a directory"}之类的错误。该文档只有12个错误代码,没有第13个。我想知道我做错了什么。

以下是我实际代码的示例。

this.path = "file:///storage/emulated/0/TheFolder/thefile.ext";
this.newPath = "file:///storage/emulated/0/NewFolder";

this.fileCtrl.copyFile(this.path, fileName, this.newPath, newFileName)

1 个答案:

答案 0 :(得分:3)

this.path必须是一个目录,但是你显示的是一些文件名

按如下方式更改您的代码

this.path = "file:///storage/emulated/0/TheFolder";
this.newPath = "file:///storage/emulated/0/NewFolder";

this.fileCtrl.copyFile(this.path, YOUR_EXISTING_FILE_NAME, this.newPath, NEW_FILE_NAME);


path -Base FileSystem
fileName - Name of file to copy
newPath - Base FileSystem of new location
newFileName - New name of file to copy to (leave blank to remain the same)