标签: fileopenpicker

Windows 10中的触摸屏友好文件选择器

我正在寻找适用于Windows 10的触摸屏友好文件选择器.在Windows 8和8.1中,我使用FileOpenPicker:

FileOpenPicker fileOpenPicker = new FileOpenPicker();

fileOpenPicker.FileTypeFilter.Add(".wma");
fileOpenPicker.FileTypeFilter.Add(".mp3");
fileOpenPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;

fileOpenPicker.ViewMode = PickerViewMode.List;

IReadOnlyList<StorageFile> files = await fileOpenPicker.PickMultipleFilesAsync();
Run Code Online (Sandbox Code Playgroud)

这产生了一个很好的界面(例子),但在Windows 10中,相同的代码显示与OpenFileDialog相同的界面(例子),这在触摸屏上很难使用.有谁知道如何在Windows 10中获得Windows 8/8.1样式的FileOpenPicker,或者知道另一种选择?

c# xaml windows-8 fileopenpicker windows-10

12
推荐指数
1
解决办法
886
查看次数

如何为 UWP 正确指定 FileOpenpicker.FileTypeFilter 语法

有没有办法像在 OpenFileDialog 中一样指定过滤器,例如

openFileDialog.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*"
Run Code Online (Sandbox Code Playgroud)

FileOpenpicker.FileTypeFilter.Add似乎不接受相同的语法。MSDN 在这些方面的信息来源很差,并且没有提供 vb.net 的示例

vb.net fileopenpicker uwp

6
推荐指数
1
解决办法
1217
查看次数

从 C# .net 框架 4.7.2 和 Microsoft.Windows.SDK.Contracts 使用 FileOpenPicker 时出现“无效窗口句柄”错误,没有 UWP

我正在尝试使用 Microsoft.Windows.SDK.Contracts 从 .net 框架 WFP 应用程序访问 Windows10 API。我想使用 FileOpenPicker() 来选择图像以供 Windows.Media.Ocr 进行 OCR 处理。但是我在使用选择器时遇到了“无效的窗口句柄”错误

我发现了一个帖子,它遇到了与 C++/WinRT类似的链接问题。其中一个答案指出“程序会崩溃,因为 FileOpenPicker 在当前线程上寻找一个 CoreWindow 作为对话框的所有者。但我们是一个没有 CoreWindow 的 Win32 桌面应用程序。” 我认为根本原因是一样的。但我不知道如何从基于 .net 框架端的代码中修复。

public async void Load()
{
    var picker = new FileOpenPicker()
    {
        SuggestedStartLocation = PickerLocationId.PicturesLibrary,
        FileTypeFilter = { ".jpg", ".jpeg", ".png", ".bmp" },
    };

    var file = await picker.PickSingleFileAsync();
    if (file != null)
    {

    }
    else
    {

    }
}
Run Code Online (Sandbox Code Playgroud)

错误消息:System.Exception:'无效的窗口句柄。(来自 HRESULT 的异常:0x80070578)'

c# wpf winforms fileopenpicker

5
推荐指数
1
解决办法
1401
查看次数

OpenFilePicker无法在Windows Phone 8上运行(不支持指定的方法)

我试图使用以下方法选择一个文件:

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;
    }
}
Run Code Online (Sandbox Code Playgroud)

...但它抛出一个异常:`不支持指定的方法.";

我复制并粘贴了Windows Phone 8文档中的代码.他们的样本都不起作用.我想也许我错过了一个文档功能/合同或其他什么,但它们甚至不存在于VS for Phone应用程序中.

为什么这不起作用?

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

FileOpenPicker openPicker …
Run Code Online (Sandbox Code Playgroud)

.net c# xaml windows-phone-8 fileopenpicker

1
推荐指数
2
解决办法
4197
查看次数