OpenFilePicker 不适用于 Windows Phone 8(不支持指定的方法) [英] OpenFilePicker not working on Windows Phone 8 (Specified method is not supported)

查看:14
本文介绍了OpenFilePicker 不适用于 Windows Phone 8(不支持指定的方法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下方法选择一个文件:

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.";

我从 Windows Phone 8 文档中复制并粘贴了代码.他们的样本都不起作用.我想也许我缺少文档功能/合同或其他任何东西,但它们甚至不存在于 VS for Phone 应用程序中.

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.

为什么这行不通?

我已经追踪到尝试的第一行:

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.

推荐答案

根据 MSDN 论坛和我假设是 MS 员工的回答 (这里:

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.

所以看起来你被 PhotoChooserTask 而不是 FileOpenPicker 卡住了.

So it looks like you are stuck with the PhotoChooserTask instead of FileOpenPicker.

这篇关于OpenFilePicker 不适用于 Windows Phone 8(不支持指定的方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆