Skip to content

Instantly share code, notes, and snippets.

@xdumaine
Created March 31, 2014 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdumaine/9900398 to your computer and use it in GitHub Desktop.
Save xdumaine/9900398 to your computer and use it in GitHub Desktop.
// Create an OpenFilePicker starting in the pictures library, viewing thumbnails
var filePicker = new FileOpenPicker();
filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
filePicker.ViewMode = PickerViewMode.Thumbnail;
// Filter to include a sample subset of file types
filePicker.FileTypeFilter.Clear();
filePicker.FileTypeFilter.Add(".bmp");
filePicker.FileTypeFilter.Add(".png");
filePicker.FileTypeFilter.Add(".jpeg");
filePicker.FileTypeFilter.Add(".jpg");
// Open a stream for the selected file
StorageFile file = await filePicker.PickSingleFileAsync();
// Ensure a file was selected
if (file == null)
{
// Get a stream of the file – I’ll use this for uploading
var stream = await file.OpenStreamForReadAsync();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment