【问题标题】:WinRT Acces denied to fileWinRT 访问拒绝文件
【发布时间】:2013-08-28 04:02:03
【问题描述】:

我遇到了这个奇怪的问题。我有一个可以使用此代码创建播放列表的应用程序

var playlist = new Windows.Media.Playlists.Playlist();  
...
WinJS.Utilities.id("appbar-save-button").listen("click", function ()
        {
            var savePicker = new Windows.Storage.Pickers.FolderPicker();
            savePicker.fileTypeFilter.append("*");

            savePicker.pickSingleFolderAsync().then(function (folder)
            {
                playlist.saveAsAsync(folder, "My Playlist", Windows.Storage.NameCollisionOption.replaceExisting, Windows.Media.Playlists.PlaylistFormat.windowsMedia);
            });

        })

当我尝试使用此代码访问此文件时出现问题

WinJS.Utilities.id("appbar-open-button").listen("click", function ()
        {
            var openPicker = Windows.Storage.Pickers.FileOpenPicker();

            openPicker.fileTypeFilter.append(".wpl");
            openPicker.pickSingleFileAsync().then(function (file)
            {
                Windows.Media.Playlists.Playlist.loadAsync(file).then(function (playlist)
                {
                    // Print the name of the playlist.
                });
            });

        })

在注释行我得到一个例外:Cannot access the specified file or folder (⑰ᑲÕ). The item is not in a location that the application has access to (including application data folders, folders that are accessible via capabilities, and persisted items in the StorageApplicationPermissions lists). Verify that the file is not marked with system or hidden file attributes.

我已经为应用程序文档库功能提供了具有类型 .wpl 的文件类型关联,但我仍然收到此异常。我该如何解决它

编辑:将视频添加到未来访问列表似乎可以解决应用创建的播放列表的问题,但对于随机播放列表,问题仍然存在。

【问题讨论】:

    标签: javascript windows-8 windows-runtime winjs windows-store


    【解决方案1】:

    据我所知,问题不在于加载“播放列表”文件的权限;如果在计算机上的任何位置选择了文件,则使用文件选择器,用户将可以访问该文件;这同样适用于文件夹选择器,在那里可以访问文件夹中的所有文件。之后,如果选择的文件/文件夹被添加到FutureAccessList,该文件夹/文件稍后也可以访问。

    播放列表可能包含用户无法访问的文件夹中的文件。要确认这一点,请尝试打开没有文件或仅在音乐库位置中的文件的播放列表 - 在为应用程序提供“音乐库”功能之后。如果这可行 - 应用程序需要设置以添加音乐文件夹。将仅加载将包含所选文件夹中的文件的播放列表。

    【讨论】:

    • 我觉得问题不在于播放列表文件,而在于其中的视频。尝试将文件中的视频添加到未来的访问列表中(或将它们移动到音乐库中)并且它有效。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-10
    • 2018-03-06
    相关资源
    最近更新 更多