【问题标题】:Get File inside a folder with getFilesAsync and getFoldersAsync使用 getFilesAsync 和 getFoldersAsync 获取文件夹内的文件
【发布时间】:2015-07-13 16:51:05
【问题描述】:

有这个

public IReadOnlyList<StorageFolder> folderList;

用它来做这个

folderList = await musicFolder.GetFoldersAsync(CommonFolderQuery.GroupByAlbum);

我应该拥有 Music 文件夹中的所有文件夹(musicFolder 是 knownfolders.musiclibrary)

但是当我在 cicle 里面时,我会尝试这样做

for (int i=0; i<folderList.Count; i++)
                    {
                        if (folderList[i].Name==(lbMusic_Albums.SelectedItem as songStruct).songName)
                        {

                            StorageFolder current = folderList[i];

                            IReadOnlyList<StorageFile> TempFileList = await current.GetFilesAsync(CommonFileQuery.OrderByName); //OTHER CODE

我在等待行系统参数异常..我不明白为什么,我是否正确传递它?

System.ArgumentException:值不在预期范围内。 在 Windows.Storage.StorageFolder.GetFilesAsync(CommonFileQuery 查询) 在 DUS.MainPage.d__31.MoveNext()

【问题讨论】:

  • 异常说明了什么?
  • 对不起,我忘记复制那部分:System.ArgumentException:值不在预期范围内。在 Windows.Storage.StorageFolder.GetFilesAsync(CommonFileQuery 查询) 在 DUS.MainPage.
  • 有什么消息吗?请让我卡住
  • 我不知道;我从未使用过这些 API。
  • 你知道其他方法吗?

标签: c# xaml windows-phone runtime


【解决方案1】:

这样解决了:D

FolderLib = await musicFolder.GetFoldersAsync(CommonFolderQuery.GroupByAlbum);
//Obtaining all the folders and do for every folder this


 foreach(StorageFolder item in FolderLib)
 {  // Take the subfolder
     SubFolderlib = await item.GetFilesAsync();
    // and do stuff with it
 }

FolderLib 和 SubFolderLib 分别是

public IReadOnlyList<StorageFile> SubFolderlib;

public IReadOnlyList<StorageFolder> FolderLib;

【讨论】:

    猜你喜欢
    • 2018-04-02
    • 2013-11-16
    • 2017-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多