How to get files from the directory under Picture Library?

老子叫甜甜 提交于 2019-12-24 12:44:08

问题


I want to know how to get files from the directory under Picture Library.(C:\Users\username\Pictures\MyFoler)

I know how to get files and folders from PicturesLibrary.

StorageFolder picturesFolder = KnownFolders.PicturesLibrary;

IReadOnlyList<StorageFile> fileLists = await picturesFolder.GetFilesAsync();
IReadOnlyList<StorageFolder> folderLists = await picturesFolder.GetFoldersAsync();

回答1:


Using the same general mechanism, StorageFolder exposes GetFoldersAsync and GetFilesAsync.

This code, added after what you have, would get a list of files in Pictures\MyFolder

StorageFolder myFolder = folderLists.Where(f => f.DisplayName == "MyFolder").FirstOrDefault();
if (myFolder != null)
{
    ReadOnlyList<StorageFile> myPictures = await myFolder.GetFilesAsync();
}


来源:https://stackoverflow.com/questions/14391321/how-to-get-files-from-the-directory-under-picture-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!