question

BitSmithy-4663 avatar image
0 Votes"
BitSmithy-4663 asked ·

How to get from folder only image files

I have code:
IReadOnlyList filesInOpenedFolder = await openedFolder.GetFilesAsync();

I want only get image files. Is it possible?
Acceptable is to get files with .gif, .jpg, .bmp extensions.

windows-uwp
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I cant edit my question but additional requirement is that: folder is an app data folder

0 Votes 0 · ·

1 Answer

FayWang-MSFT avatar image
0 Votes"
FayWang-MSFT answered ·

Hello,

​Welcome to Microsoft Q&A!


You can use QueryOptions class to query the specified file type in app data folder.



 StorageFolder folder = ApplicationData.Current.LocalFolder;
 List fileTypeFilter = new List();
 fileTypeFilter.Add(".jpg");
 fileTypeFilter.Add(".bmp");
 fileTypeFilter.Add(".gif");
 QueryOptions queryOptions = new QueryOptions(Windows.Storage.Search.CommonFileQuery.OrderByName, fileTypeFilter);
 StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(queryOptions);
 var files = await queryResult.GetFilesAsync();



· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.