使用 FileOpenPicker 打开本地数据路径 [英] Open local data path with FileOpenPicker

查看:32
本文介绍了使用 FileOpenPicker 打开本地数据路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/Data/myFiles/

/Data/myFiles/

我想在我的 Hololens 应用程序中打开上面的数据路径,该路径位于我的应用程序文件夹 (HoloApp/Data/myFiles) 的本地.据我了解,这样做的主要方法是使用 FileOpenPickers.我仔细阅读了 API 并尝试获得我可以使用的最基本、精简、简单的 FOP.

I want to open the data path above, which is local to my App folder (HoloApp/Data/myFiles), in my Hololens app. From what I understand the chief way of doing this is with FileOpenPickers. I've perused the API's and attempted to get even the most basic, stripped down, simple FOP I can make working.

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;

Task task = new Task(
async () =>
{
    StorageFile file = await openPicker.PickSingleFileAsync();
    if (file != null)
    {
        // Application now has read/write access to the picked file
        Debug.Log("Picked file: " + file.Name);
    }
    else
    {
        Debug.Log("Cancelled");
    }
});

task.Start();
task.Wait();

我已经为此苦苦挣扎了一个多星期,但一点运气都没有(我很抱歉在 UWP 应用程序开发方面很糟糕.)非常感谢任何建议、链接和鼓励

I've been struggling with this for a week+ with not a lick of luck (my apologies for being horrid at UWP app dev.) Any advice, links, encouragement is immensely appreciated

这是最新的回报:

抛出异常:mscorlib.ni.dll 中的System.Exception"

Exception thrown: 'System.Exception' in mscorlib.ni.dll

程序[4084] hololensapplication.exe"已退出,代码为 -1073741189 (0xc000027b).

The program '[4084] hololensapplication.exe' has exited with code -1073741189 (0xc000027b).

微软开发中心 对这个错误代码也没有多大帮助.

The Microsoft Dev Center isn't much help with this error code either.

private async void OpenPdfButton_Click()
{
    FileOpenPicker openPicker = new FileOpenPicker();
    openPicker.FileTypeFilter.Add(".pdf");
    StorageFile file = await openPicker.PickSingleFileAsync();
}

抛出异常:mscorlib.ni.dll 中的System.Exception"

Exception thrown: 'System.Exception' in mscorlib.ni.dll

程序[4268] hololensapplication.exe"已退出,代码为 -1073741189 (0xc000027b).

The program '[4268] hololensapplication.exe' has exited with code -1073741189 (0xc000027b).

推荐答案

你不能

根据HoloLens shell 的当前限制您不能使用内置的本机文件选择器(因为它不存在).

You can't

According to the current limitations of the HoloLens shell you cannot use the built-in native file picker (as it doesn't exist).

文件资源管理器和本地文件系统

Windows Holographic 应用模型当前未公开文件系统的概念.有已知的文件夹,但没有像 Windows 桌面版或移动版那样的内置本地文件资源管理器应用程序.应用程序可以将文件保存到其本地状态文件夹.应用还可以将文件保存到 OneDrive 等注册的文件选取器应用中.

The Windows Holographic app model does not currently expose the concept of a file system. There are known folders, but there is no built in, local File Explorer app like on Windows Desktop or Mobile. Apps can save files to their local state folders. Apps can also save files to a registered File Picker app like OneDrive.

您可以使用第三方文件选择器(如所述的 OneDrive),但这将是一个单独的 DLL,而不是 Windows.Storage

You can use a third party file picker (like OneDrive as noted) but that would be a separate DLL, not Windows.Storage

这篇关于使用 FileOpenPicker 打开本地数据路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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