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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…