public async void PopulateRecentsList() { var mostRecentlyUsed = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList; BitmapImage ItemImage = new BitmapImage(); string ItemPath = null; string ItemName; StorageItemTypes ItemType; Visibility ItemFolderImgVis; Visibility ItemEmptyImgVis; Visibility ItemFileIconVis; bool IsRecentsListEmpty = true; foreach (var entry in mostRecentlyUsed.Entries) { try { var item = await mostRecentlyUsed.GetItemAsync(entry.Token); if (item.IsOfType(StorageItemTypes.File)) { IsRecentsListEmpty = false; } } catch (Exception) {} } if (IsRecentsListEmpty) { Empty.Visibility = Visibility.Visible; } else { Empty.Visibility = Visibility.Collapsed; } foreach (Windows.Storage.AccessCache.AccessListEntry entry in mostRecentlyUsed.Entries) { string mruToken = entry.Token; try { Windows.Storage.IStorageItem item = await mostRecentlyUsed.GetItemAsync(mruToken); if (item.IsOfType(StorageItemTypes.File)) { ItemName = item.Name; ItemPath = item.Path; ItemType = StorageItemTypes.File; ItemImage = new BitmapImage(); StorageFile file = await StorageFile.GetFileFromPathAsync(ItemPath); var thumbnail = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.ListView, 30, Windows.Storage.FileProperties.ThumbnailOptions.ResizeThumbnail); if (thumbnail == null) { ItemEmptyImgVis = Visibility.Visible; } else { await ItemImage.SetSourceAsync(thumbnail.CloneStream()); ItemEmptyImgVis = Visibility.Collapsed; } ItemFolderImgVis = Visibility.Collapsed; ItemFileIconVis = Visibility.Visible; recentItemsCollection.Add(new RecentItem() { path = ItemPath, name = ItemName, type = ItemType, FolderImg = ItemFolderImgVis, EmptyImgVis = ItemEmptyImgVis, FileImg = ItemImage, FileIconVis = ItemFileIconVis }); } } catch (System.IO.FileNotFoundException) { mostRecentlyUsed.Remove(mruToken); } catch (UnauthorizedAccessException) { // Skip item until consent is provided } } if (recentItemsCollection.Count == 0) { Empty.Visibility = Visibility.Visible; } }