Windows.Storage.Pickers.FileOpenPicker.PickSingleFileAsync C# (CSharp) Method

PickSingleFileAsync() public method

public PickSingleFileAsync ( ) : IAsyncOperation
return IAsyncOperation
		public extern IAsyncOperation<StorageFile> PickSingleFileAsync();
		public extern IAsyncOperation<IVectorView<StorageFile>> PickMultipleFilesAsync();

Usage Example

        private async void ButtonFilePick_Click(object sender, RoutedEventArgs e)
        {
            var picker = new FileOpenPicker();
            picker.ViewMode = PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");

            StorageFile file = await picker.PickSingleFileAsync();


            if (file != null)
            {

                ImageProperties imgProp = await file.Properties.GetImagePropertiesAsync();
                var savedPictureStream = await file.OpenAsync(FileAccessMode.Read);

                //set image properties and show the taken photo
                bitmap = new WriteableBitmap((int)imgProp.Width, (int)imgProp.Height);
                await bitmap.SetSourceAsync(savedPictureStream);
                BBQImage.Source = bitmap;
                BBQImage.Visibility = Visibility.Visible;

                (this.DataContext as BBQRecipeViewModel).imageSource = file.Path;
            }
        }
All Usage Examples Of Windows.Storage.Pickers.FileOpenPicker::PickSingleFileAsync