我想隨便挑使用文件:OpenFilePicker(不支持指定的方法)
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;
}
}
...但它拋出一個異常:不支持'指定的方法。 「;
我從Windows Phone 8文檔複製並粘貼了代碼,他們的示例都沒有工作,我想也許我錯過了文檔功能/合同等等,但是他們甚至都不存在於VS for Phone應用程序
爲什麼不能正常工作?
我已經跟蹤它的嘗試的第一行:
FileOpenPicker openPicker = new FileOpenPicker(); // this is the line the exception is thrown on.
使用AndContinue()代替PickSingleFileAsync。有關如何使用它的詳細信息,請參閱我的答案。由於手機內存方面的考慮,windows Phone團隊需要像這樣實現它。同時打開文件選取器應用程序和您的應用程序是不可行的。相反,您的應用程序暫停,文件選取器打開,然後您的應用程序恢復。 – 2014-06-03 17:09:14