如何使用c#在PickMultipleFilesAsync()中打开或选择多个图像?

时间:2016-12-07 18:29:59

标签: c# xaml

我尝试选择多个图像(来自任何文件夹)并在图像框中显示它们。我必须使用IReadOnlyStream<>和foreach循环但如何? 我的代码的逻辑是

`FileOpenPicker fileOpenPicker = new FileOpenPicker();

        private async void button_Click(object sender, RoutedEventArgs e)
        {
        fileOpenPicker.SuggestedStartLocation = PickerLocationId.Desktop;
        fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
        fileOpenPicker.FileTypeFilter.Add(".png");
        fileOpenPicker.FileTypeFilter.Add(".jpg");
        fileOpenPicker.FileTypeFilter.Add(".jpeg");
        fileOpenPicker.FileTypeFilter.Add(".bmp");
        StorageFile file = await fileOpenPicker.PickSingleMultipleAsync(); 
        if(file != null)
        {
            textBlock.Text = file.Name;
            IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.ReadWrite);
            BitmapImage bmp = new BitmapImage();
            bmp.SetSource(fileStream);
            image1.Source = bmp;

}

0 个答案:

没有答案