DataPackage.SetStorageItems | setStorageItems methods

Applies to Windows and Windows Phone

Sets the files and folders that are contained in a DataPackage.

Overload list

MethodDescription
SetStorageItems(IIterable(IStorageItem)) Sets the files and folders contained in a DataPackage.
SetStorageItems(IIterable(IStorageItem), Boolean) Adds files and folders to a DataPackage.

Remarks

StorageItems is one of the data types that the DataPackage object supports directly. See the StandardDataFormats class for info on other supported data types.

Examples

The following example shows how to add StorageItems to a DataPackage.


function registerForShare() {
    var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
    dataTransferManager.addEventListener("datarequested", shareStorageItemsHandler);
}

function shareStorageItemsHandler(e) {
    var request = e.request;
    request.data.properties.title = "Share StorageItems Example";
    request.data.properties.description = "A demonstration that shows how to share.";
    var deferral = request.getDeferral();
    Windows.ApplicationModel.Package.current.installedLocation.getFileAsync("images\\logo.png").done(function (logoFile) {
        request.data.setStorageItems([logoFile]);
        deferral.complete();
    }, function (err) {
        request.failWithDisplayText(err);
    });
}


Requirements

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.ApplicationModel.DataTransfer
Windows::ApplicationModel::DataTransfer [C++]

Metadata

Windows.winmd

See also

DataPackage

 

 

Show:
© 2014 Microsoft