In Windows 10 we have OpenFileDialog which opens a dialog to pick the files. Here we are going to pick the image file in Windows 10.
Create new Windows 10 project and create a button and image control to perform File Picker operation.
Firstly, create a new instance for FileOpenPicker as in the following snippet:
- FileOpenPicker openPicker = new FileOpenPicker();
- openPicker.ViewMode = PickerViewMode.Thumbnail;
- openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
We need to add FileTypeFilter; it is a mandatory fields that you should add. It requires at least one type.
The FileTypeFilter is a readonly collection. We would be able to add values.
Here I am setting filter type for png and jpg images.
- openPicker.FileTypeFilter.Add(".jpg");
- openPicker.FileTypeFilter.Add(".png");
For single file selection,
- StorageFile file = await openPicker.PickSingleFileAsync();
- StorageFile file = await openPicker.PickMultipleFilesAsync();
- if (file != null)
- {
- var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
- var image = new BitmapImage();
- image.SetSource(stream);
- imageView.Source = image;
- }
- else
- {
- //
- }
- private async void openBtn_Click(object sender, RoutedEventArgs e)
- {
- FileOpenPicker openPicker = new FileOpenPicker();
- openPicker.ViewMode = PickerViewMode.Thumbnail;
- openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
- openPicker.FileTypeFilter.Add(".jpg");
- openPicker.FileTypeFilter.Add(".png");
- StorageFile file = await openPicker.PickSingleFileAsync();
- if (file != null)
- {
- var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
- var image = new BitmapImage();
- image.SetSource(stream);
- imageView.Source = image;
- }
- else
- {
- //
- }
- }
- foreach(var files in filelist)
- {
- var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
- var image = new BitmapImage();
- image.SetSource(stream);
- yourimagelist.Add(image);
- }


Source Code.


Ilker MersinliogluPosted Mar 9, 2017, 4:37 AM EST
Correction: var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); var image2 = new BitmapImage(); image2.SetSource(stream); image.Source = image2;
Ilker MersinliogluPosted Mar 9, 2017, 4:30 AM EST
Var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); var image2 = new BitmapImage(); image2.SetSource(stream); image.Source = image2;
Kumaresh RajalingamPosted Feb 19, 2016, 2:57 PM EST
good one
Kumaresh RajalingamPosted Feb 19, 2016, 2:57 PM EST
Nice explanation
Sr KarthigaPosted Feb 16, 2016, 5:11 PM EST
good one
Sr KarthigaPosted Feb 16, 2016, 5:11 PM EST
Nice explanation
Santhakumar MunuswamyPosted Nov 11, 2015, 3:51 AM EST
Good one
Vinodh NarayananPosted Nov 8, 2015, 3:04 AM EST
good one
Gowtham KTOP 100Posted Nov 7, 2015, 5:15 AM EST
Good share
Sibeesh VenuTOP 100Posted Nov 6, 2015, 10:33 PM EST
Nice Share
Harshad PansuriyaPosted Nov 6, 2015, 6:27 PM EST
Nice one
Mukesh KumarPosted Nov 6, 2015, 4:12 AM EST
Good One !