private void AddToListButton_Click(object sender, RoutedEventArgs e) { StorageFile file = rootPage.sampleFile; if (file != null) { if (MRURadioButton.IsChecked.Value) { // Add the file to app MRU and possibly system MRU RecentStorageItemVisibility visibility = SystemMRUCheckBox.IsChecked.Value ? RecentStorageItemVisibility.AppAndSystem : RecentStorageItemVisibility.AppOnly; rootPage.mruToken = StorageApplicationPermissions.MostRecentlyUsedList.Add(file, file.Name, visibility); rootPage.NotifyUser(String.Format("The file '{0}' was added to the MRU list and a token was stored.", file.Name), NotifyType.StatusMessage); } else { try { rootPage.falToken = StorageApplicationPermissions.FutureAccessList.Add(file, file.Name); rootPage.NotifyUser(String.Format("The file '{0}' was added to the FAL list and a token was stored.", file.Name), NotifyType.StatusMessage); } catch (Exception ex) when(ex.HResult == FA_E_MAX_PERSISTED_ITEMS_REACHED) { // A real program would call Remove() to create room in the FAL. rootPage.NotifyUser(String.Format("The file '{0}' was not added to the FAL list because the FAL list is full.", file.Name), NotifyType.ErrorMessage); } } } else { rootPage.NotifyUserFileNotExist(); } }
private void AddToListButton_Click(object sender, RoutedEventArgs e) { StorageFile file = rootPage.sampleFile; if (file != null) { if (MRURadioButton.IsChecked.Value) { // Add the file to app MRU and possibly system MRU RecentStorageItemVisibility visibility = SystemMRUCheckBox.IsChecked.Value ? RecentStorageItemVisibility.AppAndSystem : RecentStorageItemVisibility.AppOnly; rootPage.mruToken = StorageApplicationPermissions.MostRecentlyUsedList.Add(file, file.Name, visibility); rootPage.NotifyUser(String.Format("The file '{0}' was added to the MRU list and a token was stored.", file.Name), NotifyType.StatusMessage); } else if (FALRadioButton.IsChecked.Value) { rootPage.falToken = StorageApplicationPermissions.FutureAccessList.Add(file, file.Name); rootPage.NotifyUser(String.Format("The file '{0}' was added to the FAL list and a token was stored.", file.Name), NotifyType.StatusMessage); } } else { rootPage.NotifyUserFileNotExist(); } }