StorageItemMostRecentlyUsedList StorageItemMostRecentlyUsedList StorageItemMostRecentlyUsedList StorageItemMostRecentlyUsedList Class

Represents your app's most recently used list (MRU) (obtained from the static 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.

Syntax

Declaration

public sealed class StorageItemMostRecentlyUsedListpublic sealed class StorageItemMostRecentlyUsedListPublic NotInheritable Class StorageItemMostRecentlyUsedList

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.

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 Add(Windows.Storage.IStorageItem) and Add(Windows.Storage.IStorageItem) 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 .

Properties summary

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

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

Methods summary

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

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

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

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

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.

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.

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

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

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

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

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

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

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

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

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

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

Events summary

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

Properties

  • Entries
    Entries
    Entries
    Entries

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

    public AccessListEntryView Entries { get; }public AccessListEntryView Entries { get; }Public ReadOnly Property Entries As AccessListEntryView

    Property Value

  • MaximumItemsAllowed
    MaximumItemsAllowed
    MaximumItemsAllowed
    MaximumItemsAllowed

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

    public uint MaximumItemsAllowed { get; }public uint MaximumItemsAllowed { get; }Public ReadOnly Property MaximumItemsAllowed As uint

    Property Value

    • uint
      uint
      uint
      uint

      The maximum number of storage items.

Methods

  • Add(Windows.Storage.IStorageItem)
    Add(Windows.Storage.IStorageItem)
    Add(Windows.Storage.IStorageItem)
    Add(Windows.Storage.IStorageItem)

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

    public string Add(Windows.Storage.IStorageItem file)public string Add(Windows.Storage.IStorageItem file)Public Function Add(file As Windows.Storage.IStorageItem) As string

    Parameters

    Returns

    • string
      string
      string
      string

      A token that the app can use later to retrieve the storage item.

  • Add(Windows.Storage.IStorageItem,System.String)
    Add(Windows.Storage.IStorageItem,System.String)
    Add(Windows.Storage.IStorageItem,System.String)
    Add(Windows.Storage.IStorageItem,System.String)

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

    public string Add(Windows.Storage.IStorageItem file,System.String metadata)public string Add(Windows.Storage.IStorageItem file,System.String metadata)Public Function Add(file As Windows.Storage.IStorageItem,metadata As System.String) As string

    Parameters

    Returns

    • string
      string
      string
      string

      A token that the app can use later to retrieve the storage item.

  • Add(Windows.Storage.IStorageItem,System.String,Windows.Storage.AccessCache.RecentStorageItemVisibility)
    Add(Windows.Storage.IStorageItem,System.String,Windows.Storage.AccessCache.RecentStorageItemVisibility)
    Add(Windows.Storage.IStorageItem,System.String,Windows.Storage.AccessCache.RecentStorageItemVisibility)
    Add(Windows.Storage.IStorageItem,System.String,Windows.Storage.AccessCache.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.

    public string Add(Windows.Storage.IStorageItem file,System.String metadata,Windows.Storage.AccessCache.RecentStorageItemVisibility visibility)public string Add(Windows.Storage.IStorageItem file,System.String metadata,Windows.Storage.AccessCache.RecentStorageItemVisibility visibility)Public Function Add(file As Windows.Storage.IStorageItem,metadata As System.String,visibility As Windows.Storage.AccessCache.RecentStorageItemVisibility) As string

    Parameters

    Returns

    • string
      string
      string
      string

      A token that the app can use later to retrieve the storage item.

  • AddOrReplace(System.String,Windows.Storage.IStorageItem)
    AddOrReplace(System.String,Windows.Storage.IStorageItem)
    AddOrReplace(System.String,Windows.Storage.IStorageItem)
    AddOrReplace(System.String,Windows.Storage.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.

    public void AddOrReplace(System.String token,Windows.Storage.IStorageItem file)public void AddOrReplace(System.String token,Windows.Storage.IStorageItem file)Public Function AddOrReplace(token As System.String,file As Windows.Storage.IStorageItem) As void

    Parameters

    • token
      System.String
      System.String
      System.String
      System.String

      The token associated with the new storage item. If the access list already contains a storage item that has this token, the new item replaces the existing one.

    • file

      The storage item to add or replace.

  • AddOrReplace(System.String,Windows.Storage.IStorageItem,System.String)
    AddOrReplace(System.String,Windows.Storage.IStorageItem,System.String)
    AddOrReplace(System.String,Windows.Storage.IStorageItem,System.String)
    AddOrReplace(System.String,Windows.Storage.IStorageItem,System.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.

    public void AddOrReplace(System.String token,Windows.Storage.IStorageItem file,System.String metadata)public void AddOrReplace(System.String token,Windows.Storage.IStorageItem file,System.String metadata)Public Function AddOrReplace(token As System.String,file As Windows.Storage.IStorageItem,metadata As System.String) As void

    Parameters

    • token
      System.String
      System.String
      System.String
      System.String

      The token associated with the new storage item. If the access list already contains a storage item that has this token, the new item replaces the existing one.

    • file

      The storage item to add or replace.

    • metadata
      System.String
      System.String
      System.String
      System.String

      Optional metadata to associate with the storage item.

  • AddOrReplace(System.String,Windows.Storage.IStorageItem,System.String,Windows.Storage.AccessCache.RecentStorageItemVisibility)
    AddOrReplace(System.String,Windows.Storage.IStorageItem,System.String,Windows.Storage.AccessCache.RecentStorageItemVisibility)
    AddOrReplace(System.String,Windows.Storage.IStorageItem,System.String,Windows.Storage.AccessCache.RecentStorageItemVisibility)
    AddOrReplace(System.String,Windows.Storage.IStorageItem,System.String,Windows.Storage.AccessCache.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.

    public void AddOrReplace(System.String token,Windows.Storage.IStorageItem file,System.String metadata,Windows.Storage.AccessCache.RecentStorageItemVisibility visibility)public void AddOrReplace(System.String token,Windows.Storage.IStorageItem file,System.String metadata,Windows.Storage.AccessCache.RecentStorageItemVisibility visibility)Public Function AddOrReplace(token As System.String,file As Windows.Storage.IStorageItem,metadata As System.String,visibility As Windows.Storage.AccessCache.RecentStorageItemVisibility) As void

    Parameters

  • CheckAccess(Windows.Storage.IStorageItem)
    CheckAccess(Windows.Storage.IStorageItem)
    CheckAccess(Windows.Storage.IStorageItem)
    CheckAccess(Windows.Storage.IStorageItem)

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

    public bool CheckAccess(Windows.Storage.IStorageItem file)public bool CheckAccess(Windows.Storage.IStorageItem file)Public Function CheckAccess(file As Windows.Storage.IStorageItem) As bool

    Parameters

    Returns

    • bool
      bool
      bool
      bool

      True if the app can access the storage item; otherwise false.

  • Clear()
    Clear()
    Clear()
    Clear()

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

    public void Clear()public void Clear()Public Function Clear() As void
  • ContainsItem(System.String)
    ContainsItem(System.String)
    ContainsItem(System.String)
    ContainsItem(System.String)

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

    public bool ContainsItem(System.String token)public bool ContainsItem(System.String token)Public Function ContainsItem(token As System.String) As bool

    Parameters

    • token
      System.String
      System.String
      System.String
      System.String

      The token of the storage item to look for.

    Returns

    • bool
      bool
      bool
      bool

      True if the most recently used (MRU) list contains the specified storage item; false otherwise.

  • GetFileAsync(System.String)
    GetFileAsync(System.String)
    GetFileAsync(System.String)
    GetFileAsync(System.String)

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

    public IAsyncOperation<StorageFile> GetFileAsync(System.String token)public IAsyncOperation<StorageFile> GetFileAsync(System.String token)Public Function GetFileAsync(token As System.String) As IAsyncOperation( Of StorageFile )

    Parameters

    • token
      System.String
      System.String
      System.String
      System.String

      The token of the StorageFile to retrieve.

    Returns

    • When this method completes successfully, it returns the StorageFile that is associated with the specified token.

  • GetFileAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)
    GetFileAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)
    GetFileAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)
    GetFileAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)

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

    public IAsyncOperation<StorageFile> GetFileAsync(System.String token,Windows.Storage.AccessCache.AccessCacheOptions options)public IAsyncOperation<StorageFile> GetFileAsync(System.String token,Windows.Storage.AccessCache.AccessCacheOptions options)Public Function GetFileAsync(token As System.String,options As Windows.Storage.AccessCache.AccessCacheOptions) As IAsyncOperation( Of StorageFile )

    Parameters

    Returns

    • When this method completes successfully, it returns the StorageFile that is associated with the specified token.

  • GetFolderAsync(System.String)
    GetFolderAsync(System.String)
    GetFolderAsync(System.String)
    GetFolderAsync(System.String)

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

    public IAsyncOperation<StorageFolder> GetFolderAsync(System.String token)public IAsyncOperation<StorageFolder> GetFolderAsync(System.String token)Public Function GetFolderAsync(token As System.String) As IAsyncOperation( Of StorageFolder )

    Parameters

    • token
      System.String
      System.String
      System.String
      System.String

      The token of the StorageFolder to retrieve.

    Returns

    • When this method completes successfully, it returns the StorageFolder that is associated with the specified token.

  • GetFolderAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)
    GetFolderAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)
    GetFolderAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)
    GetFolderAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)

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

    public IAsyncOperation<StorageFolder> GetFolderAsync(System.String token,Windows.Storage.AccessCache.AccessCacheOptions options)public IAsyncOperation<StorageFolder> GetFolderAsync(System.String token,Windows.Storage.AccessCache.AccessCacheOptions options)Public Function GetFolderAsync(token As System.String,options As Windows.Storage.AccessCache.AccessCacheOptions) As IAsyncOperation( Of StorageFolder )

    Parameters

    Returns

    • When this method completes successfully, it returns the StorageFolder that is associated with the specified token.

  • GetItemAsync(System.String)
    GetItemAsync(System.String)
    GetItemAsync(System.String)
    GetItemAsync(System.String)

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

    public IAsyncOperation<IStorageItem> GetItemAsync(System.String token)public IAsyncOperation<IStorageItem> GetItemAsync(System.String token)Public Function GetItemAsync(token As System.String) As IAsyncOperation( Of IStorageItem )

    Parameters

    • token
      System.String
      System.String
      System.String
      System.String

      The token of the item to retrieve.

    Returns

    • When this method completes successfully, it returns the item (type IStorageItem ) that is associated with the specified token.

  • GetItemAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)
    GetItemAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)
    GetItemAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)
    GetItemAsync(System.String,Windows.Storage.AccessCache.AccessCacheOptions)

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

    public IAsyncOperation<IStorageItem> GetItemAsync(System.String token,Windows.Storage.AccessCache.AccessCacheOptions options)public IAsyncOperation<IStorageItem> GetItemAsync(System.String token,Windows.Storage.AccessCache.AccessCacheOptions options)Public Function GetItemAsync(token As System.String,options As Windows.Storage.AccessCache.AccessCacheOptions) As IAsyncOperation( Of IStorageItem )

    Parameters

    Returns

    • When this method completes successfully, it returns the item (type IStorageItem ) that is associated with the specified token.

  • Remove(System.String)
    Remove(System.String)
    Remove(System.String)
    Remove(System.String)

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

    public void Remove(System.String token)public void Remove(System.String token)Public Function Remove(token As System.String) As void

    Parameters

    • token
      System.String
      System.String
      System.String
      System.String

      The token of the storage item to remove.

Events

  • ItemRemoved
    ItemRemoved
    ItemRemoved
    ItemRemoved

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

    public event TypedEventHandler ItemRemovedpublic event TypedEventHandler ItemRemovedPublic Event ItemRemoved

    Remarks

    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.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute

Details

Assembly

Windows.Storage.AccessCache.dll