使用 getFilesAsync 和 getFoldersAsync 获取文件夹中的文件
Get File inside a folder with getFilesAsync and getFoldersAsync
有了这个
public IReadOnlyList<StorageFolder> folderList;
并用它来做
folderList = await musicFolder.GetFoldersAsync(CommonFolderQuery.GroupByAlbum);
我应该把所有文件夹都放在 Music 文件夹中(musicFolder 是 knownfolders.musiclibrary)
但是当我在一个圆环内时,我尝试做
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: Value does not fall within the expected range.
at Windows.Storage.StorageFolder.GetFilesAsync(CommonFileQuery query)
at DUS.MainPage.d__31.MoveNext()
这样解决了: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;
有了这个
public IReadOnlyList<StorageFolder> folderList;
并用它来做
folderList = await musicFolder.GetFoldersAsync(CommonFolderQuery.GroupByAlbum);
我应该把所有文件夹都放在 Music 文件夹中(musicFolder 是 knownfolders.musiclibrary)
但是当我在一个圆环内时,我尝试做
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: Value does not fall within the expected range. at Windows.Storage.StorageFolder.GetFilesAsync(CommonFileQuery query) at DUS.MainPage.d__31.MoveNext()
这样解决了: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;