Dela via


StandardDataFormats.StorageItems Property

Definition

A read-only property that returns the format ID string value corresponding to the storage item format (for files and folders).

public:
 static property Platform::String ^ StorageItems { Platform::String ^ get(); };
static winrt::hstring StorageItems();
public static string StorageItems { get; }
var string = StandardDataFormats.storageItems;
Public Shared ReadOnly Property StorageItems As String

Property Value

String

Platform::String

winrt::hstring

The format ID string value corresponding to the storage item format (for files and folders).

Examples

This example demonstrates the use of the StorageItems property. For more examples, see the Clipboard sample and the ShareTarget sample.

public async Task ActivateAsync(ShareTargetActivatedEventArgs args)
{
    ShareOperation shareOperation = args.ShareOperation;
    if (shareOperation.Data.Contains(StandardDataFormats.Text))
    {
        string text = await shareOperation.Data.GetTextAsync();

        // To output the text from this example, you need a TextBlock control
        // with a name of "sharedContent".
        sharedContent.Text = "Text: " + text;
    }

    if (shareOperation.Data.Contains(StandardDataFormats.StorageItems)) 
    {
        shareOperation.ReportStarted();
        IReadOnlyList<IStorageItem> storageItems = null;
        storageItems = await shareOperation.Data.GetStorageItemsAsync();
        string fileList = String.Empty;

        for (int index = 0; index < storageItems.Count; index++) 
        {
            fileList += storageItems[index].Name;
                if (index < storageItems.Count - 1) {
                    fileList += ", ";
                }
            }

        // To output the text from this example, you need a TextBlock control
        // with a name of "sharedContent".
        sharedContent.Text += "StorageItems: " + fileList + Environment.NewLine;

        shareOperation.ReportCompleted();
    }

    Window.Current.Content = this;
    Window.Current.Activate();
}

Applies to