有没有办法将文件从源应用程序文件夹中的任何位置复制到设备的文档目录?我一直在查看文件系统插件文档,但找不到有关此主题的任何内容。
最佳答案
仔细看看cookbook docs,似乎您可以创建对设备文档文件夹的引用,如下所示:
var documents = fs.knownFolders.documents();
然后,您可以使用类似这样的内容从您的应用程序获取文件(?)。其中路径是对应用程序中捆绑的文件的引用:
var myFile = fs.File.fromPath(path);
所以你可以这样做:
// Writing text to the file.
myFile.readText()
.then(function (content) {
// Successfully read the file's content.
documents.writeText(content)
.then(function () {
// Succeeded writing to the file.
}, function (error) {
// Failed to write to the file.
});
}, function (error) {
// Failed to read from the file.
});
关于nativescript - (Nativescript) 将文件从 bundle 复制到文档目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38673605/