I am trying to just pick a file using:
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
try
{
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
// Application now has read/write access to the picked file
txt.Text = "Picked file: " + file.Name;
}
else
{
txt.Text = "Operation cancelled.";
}
}
catch (Exception exception)
{
txt.Text = exception.Message;
}
}
...but It throws an exception: `Specified method is not supported.";
I copied and pasted the code from the Windows Phone 8 docs. None of their samples work. I thought that maybe I am missing a Documents capability/Contract or whatever but they don't even exist in VS for Phone apps.
Why won't this work?
I have tracked it down to the very first line of the try:
FileOpenPicker openPicker = new FileOpenPicker(); // this is the line the exception is thrown on.
According to the MSDN-forums and an answer from what i assume is a MS employee (here):
We do not currently support choosing files other than photos or choosing files from other Store apps.
So it looks like you are stuck with the PhotoChooserTask
instead of FileOpenPicker
.