StorageLibrary
StorageLibrary
StorageLibrary
StorageLibrary
Class
Definition
Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Prerelease APIs are identified by a Prerelease label.
[Contains prerelease APIs.]
Lets you add and remove folders from a library like Music or Videos and lets you get a list of folders included in the library.
public : sealed class StorageLibrary : IStorageLibrary, IStorageLibrary2, IStorageLibrary3public sealed class StorageLibrary : IStorageLibrary, IStorageLibrary2, IStorageLibrary3Public NotInheritable Class StorageLibrary Implements IStorageLibrary, IStorageLibrary2, IStorageLibrary3// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Remarks
You can only access libraries that you have declared capabilities for in your app manifest. To learn more about capabilities see, App capability declarations.
Properties
ChangeTracker ChangeTracker ChangeTracker ChangeTracker
Returns the StorageLibraryChangeTracker associated with the storage library.
public : StorageLibraryChangeTracker ChangeTracker { get; }public StorageLibraryChangeTracker ChangeTracker { get; }Public ReadOnly Property ChangeTracker As StorageLibraryChangeTracker// You can use this property in JavaScript.
- Value
- StorageLibraryChangeTracker StorageLibraryChangeTracker StorageLibraryChangeTracker StorageLibraryChangeTracker
The StorageLibraryChangeTracker associated with the storage library.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Folders Folders Folders Folders
Gets the folders in the current library.
public : IObservableVector<StorageFolder> Folders { get; }public IObservableVector<StorageFolder> Folders { get; }Public ReadOnly Property Folders As IObservableVector<StorageFolder>// You can use this property in JavaScript.
- Value
- IObservableVector<StorageFolder> IObservableVector<StorageFolder> IObservableVector<StorageFolder> IObservableVector<StorageFolder>
The folders in the current storage library.
- See Also
SaveFolder SaveFolder SaveFolder SaveFolder
Get the default save folder for the current library.
public : StorageFolder SaveFolder { get; }public StorageFolder SaveFolder { get; }Public ReadOnly Property SaveFolder As StorageFolder// You can use this property in JavaScript.
The default save folder for the current library.
Methods
AreFolderSuggestionsAvailableAsync() AreFolderSuggestionsAvailableAsync() AreFolderSuggestionsAvailableAsync() AreFolderSuggestionsAvailableAsync()
Prerelease. Determines if there are suggestions for adding existing folders with content to the StorageLibrary.
public : IAsyncOperation<PlatForm::Boolean> AreFolderSuggestionsAvailableAsync()public IAsyncOperation<bool> AreFolderSuggestionsAvailableAsync()Public Function AreFolderSuggestionsAvailableAsync() As IAsyncOperation( Of bool )// You can use this method in JavaScript.
True if there are folder suggestions; False otherwise
| Device family |
Windows 10 Insider Preview (introduced v10.0.16257.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v5)
|
Examples
This example demonstrates how to determine whether there are any suggested folders with content that can be added to your Pictures library.
private async Task<StorageLibrary> SetupPicturesLibraryAsync()
{
if (this.picturesLibrary == null)
{
this.picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);
this.picturesLibrary.DefinitionChanged += PicturesLibrary_DefinitionChanged;
}
return this.picturesLibrary;
}
private async void CheckForFolderSuggestions_Clicked(object sender, RoutedEventArgs e)
{
var library = await SetupPicturesLibraryAsync();
if (await library.AreFolderSuggestionsAvailableAsync())
{
// There are new folders that could be added to the library.
// Prompt the user to add one or more of them.
// Note that the RequestAddFolderAsync method returns only one folder.
// If the user adds multiple folders, only one will be returned.
// In this example, to keep track of all the added folders, the app can subscribe to the
// StorageLibrary.DefinitionChanged event by awaiting library.RequestAddFolderAsync();
// Launch the folder suggestion dialog
var folder = await library.RequestAddFolderAsync();
}
}
private void PicturesLibrary_DefinitionChanged(StorageLibrary sender, object args)
{
foreach (StorageFolder folder in sender.Folders)
{
// Do something with every folder in the library
}
}
Note
Don't forget to include the picturesLibrary capability in your app's package manifest. For more information on Capabilities in the manifest, see App capability declarations.
Remarks
If this feature is not supported on your version of Windows, the method will return false.
GetLibraryAsync(KnownLibraryId) GetLibraryAsync(KnownLibraryId) GetLibraryAsync(KnownLibraryId) GetLibraryAsync(KnownLibraryId)
Gets the specified library.
public : static IAsyncOperation<StorageLibrary> GetLibraryAsync(KnownLibraryId libraryId)public static IAsyncOperation<StorageLibrary> GetLibraryAsync(KnownLibraryId libraryId)Public Static Function GetLibraryAsync(libraryId As KnownLibraryId) As IAsyncOperation( Of StorageLibrary )// You can use this method in JavaScript.
A KnownLibraryId value that identifies the library to retrieve, like Music or Videos.
When this method completes successfully, it returns the library (type StorageLibrary ).
- See Also
GetLibraryForUserAsync(User, KnownLibraryId) GetLibraryForUserAsync(User, KnownLibraryId) GetLibraryForUserAsync(User, KnownLibraryId) GetLibraryForUserAsync(User, KnownLibraryId)
Gets the specified library for a User.
public : static IAsyncOperation<StorageLibrary> GetLibraryForUserAsync(User user, KnownLibraryId libraryId)public static IAsyncOperation<StorageLibrary> GetLibraryForUserAsync(User user, KnownLibraryId libraryId)Public Static Function GetLibraryForUserAsync(user As User, libraryId As KnownLibraryId) As IAsyncOperation( Of StorageLibrary )// You can use this method in JavaScript.
A KnownLibraryId value that identifies the library to retrieve, like Music or Videos.
When this method completes successfully, it returns the library (type StorageLibrary ).
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
- See Also
RequestAddFolderAsync() RequestAddFolderAsync() RequestAddFolderAsync() RequestAddFolderAsync()
Prompts the user to select a folder, and then adds the folder to the library.
public : IAsyncOperation<StorageFolder> RequestAddFolderAsync()public IAsyncOperation<StorageFolder> RequestAddFolderAsync()Public Function RequestAddFolderAsync() As IAsyncOperation( Of StorageFolder )// You can use this method in JavaScript.
When this method completes, it returns the folder that the user picked and added as a StorageFolder. If the user cancels the operation and doesn't pick a folder, the method returns null.
Remarks
The file picker displayed lets user select only library-eligible locations.
- See Also
RequestRemoveFolderAsync(StorageFolder) RequestRemoveFolderAsync(StorageFolder) RequestRemoveFolderAsync(StorageFolder) RequestRemoveFolderAsync(StorageFolder)
Prompts the user to confirm removal of the specified folder from the current library, and then removes the folder.
public : IAsyncOperation<PlatForm::Boolean> RequestRemoveFolderAsync(StorageFolder folder)public IAsyncOperation<bool> RequestRemoveFolderAsync(StorageFolder folder)Public Function RequestRemoveFolderAsync(folder As StorageFolder) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
The folder to remove.
Returns true if the folder was removed; otherwise false.
Remarks
Important
This method must be called from a UI thread.
- See Also
Events
DefinitionChanged DefinitionChanged DefinitionChanged DefinitionChanged
Occurs when the list of folders in the current library changes.
public : event TypedEventHandler DefinitionChanged<StorageLibrary, object>public event TypedEventHandler DefinitionChanged<StorageLibrary, object>Public Event DefinitionChanged<StorageLibrary, object>// You can use this event in JavaScript.