private async void addButton_Click(object sender, RoutedEventArgs e) { StorageLibrary musicLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music); StorageFolder result = await musicLibrary.RequestAddFolderAsync(); if (result != null) { LoadFolders(); Collection.LoadCollectionChanges(); } }
async void knowLibrary() { StorageLibrary pic = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures); IObservableVector <StorageFolder> myPictureFolders = pic.Folders; //将现有文件添加到文件库中 StorageFolder newFolder = await pic.RequestAddFolderAsync(); //文件夹中移除子文件夹 //bool result = await picture.RequestRemoveFolderAsync(); pic.DefinitionChanged += MyPictures_DefinitionChanged; }
/// <summary> /// Displays the folder Picker to request that the user select a folder that will be added to the /// Pictures library. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void AddFolderButton_Click(object sender, RoutedEventArgs e) { StorageLibrary picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures); StorageFolder folderAdded = await picturesLibrary.RequestAddFolderAsync(); if (folderAdded != null) { OutputTextBlock.Text = folderAdded.DisplayName + " was added to the Pictures library."; } else { OutputTextBlock.Text = "Operation canceled."; } }
public async void OnSelectLibrary() { StorageLibrary storageLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music); StorageFolder libraryRoot = await storageLibrary.RequestAddFolderAsync(); var paths = storageLibrary.Folders.Select(f => f.Path); if (libraryRoot != null) { LibraryService.SetupLibrary(libraryRoot); SelectorVisibility.Value = Visibility.Collapsed; ProgressRingVisiblity.Value = Visibility.Visible; await LibraryService.LoadLibrary(); } }