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

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

问题描述

/Data/myFiles/

/Data/myFiles/

我想在Hololens应用程序中打开上述数据路径,该数据路径位于我的App文件夹(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 app开发人员面前表现得很差.)任何建议,链接和鼓励都深表感谢.

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).

Microsoft开发人员中心对于此错误代码也没有太大帮助.

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应用程序模型当前未公开文件系统的概念.有已知的文件夹,但没有内置的本地File Explorer应用程序,例如Windows Desktop或Mobile.应用程序可以将文件保存到其本地状态文件夹中.应用程序还可以将文件保存到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天全站免登陆