读取文件系统 Windows apache cordova 应用程序

Reading file system Windows apache cordova app

我正在使用 cordova-file 插件来读取我存储在我的应用程序中的文件并加载它以供用户查看。

我有以下代码:

function readFileName(identifier) {
        var ret = ""
        var directory = cordova.file.applicationDirectory + "www/presentations/files/";
        var fileName = identifier.getAttribute("data-link")
        window.resolveLocalFileSystemURL(directory, function (directoryEntry) {
            directoryEntry.getFile(fileName, { create: false }, function (fileEntry) {
                ret = fileEntry.nativeURL;
            }, ret = null);
        }, fail);
        return ret;
    }

目录解析为 ms-appx:///www/presentations/files/

该代码在 Android 中运行良好,但在 Windows 应用程序中,它 returns 错误代码 5,根据文档为 ENCODING_ERR。

我假设这是因为我的文件路径不正确,但文档说 ApplicationStorage 在 Windows 10 上工作并且没有发现任何表明 www/presentations/files/ 文件夹不存在(它肯定存在于我的 deug 文件夹中)。

我很难弄清楚如何解决。即使我尝试像这样解析根目录:

 window.resolveLocalFileSystemURL(directory, function (directoryEntry) {
            var reader = directoryEntry.createReader();
            reader.readEntries(function success(entries) {
                var i;
                for (i = 0; i < entries.length; i++) {

                    console.log('En - ', entries[i].fileName);
                }
            }, fail);

我仍然遇到同样的错误。任何指针将不胜感激。

编辑:

我查看了以下错误

https://github.com/Reon90/cordova-plugin-file/blob/a4df917e66d0c35cb3e11ca3257f54b8b7dd3eab/src/windows/FileProxy.js

我已将更改应用于文件,但仍然出现相同的错误

I have looked at the following bug https://github.com/Reon90/cordova-plugin-file/blob/a4df917e66d0c35cb3e11ca3257f54b8b7dd3eab/src/windows/FileProxy.js I have applied the change to the file but am still getting the same error

我制作了一个演示并尝试使用此 link 中的代码修复它。一开始没用。但是在我再次使用命令 cordova platform rm windows 和 运行 删除了 windows 平台之后,应用程序。有效!

注意:有关解决问题的详细信息,请参阅Changes made to FileProxy.js