Windows Dev Center

StorageItemMostRecentlyUsedList.Add(IStorageItem) | add(IStorageItem) method

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

Syntax


var string = storageItemMostRecentlyUsedList.add(file);

Parameters

file

Type: IStorageItem

The storage item to add.

Return value

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

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

Examples

This example shows you how to use this Add method of the MRU list to store a file that was picked by the user so that you can keep track of the users most recently used files.



var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.pickSingleFileAsync().then(function (pickedFile) {
    if (pickedFile) {
        // Store the file to access again later
        var listToken = Windows.Storage.AccessCache.StorageApplicationPermissions.mostRecentlyUsedList.add(pickedFile);

        // Add code to process the file that the user picked
    } else {
        // No file
    }
});

Make sure you check that a file was picked before you process the pickedFile (a StorageFile object), as shown in the example.

Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Storage.AccessCache
Windows::Storage::AccessCache [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Storage.AccessCache
Windows::Storage::AccessCache [C++]

Metadata

Windows.winmd

See also

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

 

 

Show:
© 2015 Microsoft