StandardDataFormats.StorageItems 属性

定义

一个只读属性,返回与文件和文件夹) 的存储项格式 (对应的格式 ID 字符串值。

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

属性值

String

Platform::String

winrt::hstring

与文件和文件夹) 的存储项格式 (对应的格式 ID 字符串值。

示例

此示例演示如何使用 StorageItems 属性。 有关更多示例,请参阅 剪贴板示例ShareTarget 示例

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();
}

适用于