StorageItemMostRecentlyUsedList StorageItemMostRecentlyUsedList StorageItemMostRecentlyUsedList StorageItemMostRecentlyUsedList StorageItemMostRecentlyUsedList Class

Definition

Represents your app's most recently used list (MRU) (obtained from the static StorageApplicationPermissions.MostRecentlyUsedList property). You use your MRU to track items (files and/or folders) that the user has accessed most recently. Items are stored in the MRU as StorageFile and StorageFolder objects.

public : sealed class StorageItemMostRecentlyUsedList : IStorageItemAccessList, IStorageItemMostRecentlyUsedList, IStorageItemMostRecentlyUsedList2
struct winrt::Windows::Storage::AccessCache::StorageItemMostRecentlyUsedList : IStorageItemAccessList, IStorageItemMostRecentlyUsedList, IStorageItemMostRecentlyUsedList2
public sealed class StorageItemMostRecentlyUsedList : IStorageItemAccessList, IStorageItemMostRecentlyUsedList, IStorageItemMostRecentlyUsedList2
Public NotInheritable Class StorageItemMostRecentlyUsedList Implements IStorageItemAccessList, IStorageItemMostRecentlyUsedList, IStorageItemMostRecentlyUsedList2
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

This example demonstrates how to add an item to the app's FutureAccessList and MostRecentlyUsedList.

StorageFile file = await savePicker.PickSaveFileAsync();
if (file != null)
{
    // Add to MRU with metadata (For example, a string that represents the date)
    string mruToken = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList.Add(file, "20120716");

    // Add to FA without metadata
    string faToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file);  
}
else
{
    // The file picker was dismissed with no file selected to save
}
savePicker.pickSaveFileAsync().then(function (file) {
    if (file) {
        // Add to MRU with metadata (For example, a string that represents the date)
        var mruToken = StorageApplicationPermissions.mostRecentlyUsedList.add(file, "20120716");

        // Add to FA without metadata
        var faToken = Windows.Storage.AccessCache.StorageApplicationPermissions.futureAccessList.add(file);
    } else {
        // The file picker was dismissed with no file selected to save
    }
});

We recommend that you store the tokens that are returned by StorageApplicationPermissions.MostRecentlyUsedList.Add and StorageApplicationPermissions.FutureAccessList.Add so that you can use them to retrieve the respective list entry for the item that you added. In the example, we store the tokens in mruToken and faToken respectively but we don't do anything else with them.

Additionally, the savePicker variable in the example contains a FileSavePicker object that was created by the sample. To learn more about saving files with file picker, see How to save files through . To learn about accessing files, see Quickstart: Accessing files with .

Remarks

Use the most recently used (MRU) list to track files and/or locations that your user accesses frequently.

This list can store up to 25 items. While the app must add items to the MRU in order to track them, Windows maintains the 25-item limit by removing stale items if necessary.

Note

If you want to respond to ItemRemoved events you must register your event handle every time you get a new reference to the StorageItemMostRecentlyUsedList.

To see more code examples, see the File picker sample and the File access sample.

To learn about using the FutureAccessList and MostRecentlyUsedList, see How to track recently used files and folders.

To learn more about what files and locations your app has permission to access, see File access permissions.

Properties

Entries Entries Entries Entries Entries

Gets an object for retrieving storage items from the most recently used (MRU) list.

MaximumItemsAllowed MaximumItemsAllowed MaximumItemsAllowed MaximumItemsAllowed MaximumItemsAllowed

Gets the maximum number of storage items that the most recently used (MRU) list can contain.

Methods

Add(IStorageItem) Add(IStorageItem) Add(IStorageItem) Add(IStorageItem) Add(IStorageItem)

Adds a new storage item to the most recently used (MRU) list.

Add(IStorageItem, String) Add(IStorageItem, String) Add(IStorageItem, String) Add(IStorageItem, String) Add(IStorageItem, String)

Adds a new storage item and accompanying metadata to the most recently used (MRU) list.

Add(IStorageItem, String, RecentStorageItemVisibility) Add(IStorageItem, String, RecentStorageItemVisibility) Add(IStorageItem, String, RecentStorageItemVisibility) Add(IStorageItem, String, RecentStorageItemVisibility) Add(IStorageItem, String, RecentStorageItemVisibility)

Adds a new storage item and accompanying metadata to the most recently used (MRU) list, specifying the extent of its visibility in the list.

AddOrReplace(String, IStorageItem) AddOrReplace(String, IStorageItem) AddOrReplace(String, IStorageItem) AddOrReplace(String, IStorageItem) AddOrReplace(String, IStorageItem)

Adds a new storage item to the most recently used (MRU) list, or replaces the specified item if it already exists in the list.

AddOrReplace(String, IStorageItem, String) AddOrReplace(String, IStorageItem, String) AddOrReplace(String, IStorageItem, String) AddOrReplace(String, IStorageItem, String) AddOrReplace(String, IStorageItem, String)

Adds a new storage item and accompanying metadata to the most recently used (MRU) list, or replaces the specified item if it already exists in the list.

AddOrReplace(String, IStorageItem, String, RecentStorageItemVisibility) AddOrReplace(String, IStorageItem, String, RecentStorageItemVisibility) AddOrReplace(String, IStorageItem, String, RecentStorageItemVisibility) AddOrReplace(String, IStorageItem, String, RecentStorageItemVisibility) AddOrReplace(String, IStorageItem, String, RecentStorageItemVisibility)

Adds a new storage item and accompanying metadata to the most recently used (MRU) list, or replaces the specified item if it already exists in the list. Also specifies the extent of its visibility in the list.

CheckAccess(IStorageItem) CheckAccess(IStorageItem) CheckAccess(IStorageItem) CheckAccess(IStorageItem) CheckAccess(IStorageItem)

Determines whether the app has access to the specified storage item in the most recently used (MRU) list.

Clear() Clear() Clear() Clear() Clear()

Removes all storage items from the most recently used (MRU) list.

ContainsItem(String) ContainsItem(String) ContainsItem(String) ContainsItem(String) ContainsItem(String)

Determines whether the most recently used (MRU) list contains the specified storage item.

GetFileAsync(String) GetFileAsync(String) GetFileAsync(String) GetFileAsync(String) GetFileAsync(String)

Retrieves the specified storageFile from the most recently used (MRU) list.

GetFileAsync(String, AccessCacheOptions) GetFileAsync(String, AccessCacheOptions) GetFileAsync(String, AccessCacheOptions) GetFileAsync(String, AccessCacheOptions) GetFileAsync(String, AccessCacheOptions)

Retrieves the specified storageFile from the most recently used (MRU) list using the specified options.

GetFolderAsync(String) GetFolderAsync(String) GetFolderAsync(String) GetFolderAsync(String) GetFolderAsync(String)

Retrieves the specified StorageFolder from the most recently used (MRU) list.

GetFolderAsync(String, AccessCacheOptions) GetFolderAsync(String, AccessCacheOptions) GetFolderAsync(String, AccessCacheOptions) GetFolderAsync(String, AccessCacheOptions) GetFolderAsync(String, AccessCacheOptions)

Retrieves the specified StorageFolder from the most recently used (MRU) list using the specified options.

GetItemAsync(String) GetItemAsync(String) GetItemAsync(String) GetItemAsync(String) GetItemAsync(String)

Retrieves the specified item (like a file or folder) from the most recently used (MRU) list.

GetItemAsync(String, AccessCacheOptions) GetItemAsync(String, AccessCacheOptions) GetItemAsync(String, AccessCacheOptions) GetItemAsync(String, AccessCacheOptions) GetItemAsync(String, AccessCacheOptions)

Retrieves the specified item (like a file or folder) from the most recently used (MRU) list using the specified options.

Remove(String) Remove(String) Remove(String) Remove(String) Remove(String)

Removes the specified storage item from the most recently used (MRU) list.

Events

ItemRemoved ItemRemoved ItemRemoved ItemRemoved ItemRemoved

Fires when a storage item is removed from the most recently used (MRU) list.

See Also