Issues with Windows 10 release
I am trying to follow instructions to get files from known folders in windows 10 like below,
https://msdn.microsoft.com/en-us/library/windows/apps/br227275.aspx
try
{
StorageFolder folder = KnownFolders.PicturesLibrary;
IReadOnlyList<StorageFile> pics = await folder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByDate, 0, 20);
Debug.WriteLine(pics.Count);
}
catch(Exception ex)
{
Debug.WriteLine(ex.Message);
}
The same code works in the WindowsPhone 8.1 SDK. But this is not the case on Windows 10 mobile. The exception I get is this,
The specified query parameters are not available for this folder because it is not in the library or homegroup. Only folders in the Library or Homegroup support all options.
Any ideas on how to fix this?
source to share
You need to provide a library of image access capabilities and link information to it.
Go to your application's Solution Explorer -> then "Package.appxmanifest" -> then "Features" -> Select "Image Library" (if not selected, select it).
After restoring your project, you should be able to run your code successfully. Hope this helps you :-)
source to share
Updated answer, below code works, its tested
StorageFolder folder = KnownFolders.PicturesLibrary;
StorageFileQueryResult query = folder.CreateFileQuery(Windows.Storage.Search.CommonFileQuery.OrderByDate);
IReadOnlyList<StorageFile> pics = await query.GetFilesAsync(0, 20);
Debug.WriteLine(pics.Count);
there is an example for getting requests for folders on MSDN, applies the same for file requests https://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj150593.ASP
source to share