使用FileOpenPicker打开本地数据路径

时间:2017-06-30 15:40:29

标签: c# unity3d uwp hololens fileopenpicker

/数据/ MYFILES /

我想在我的Hololens应用中打开上面的数据路径,这是我的App文件夹(HoloApp / Data / myFiles)的本地数据路径。根据我的理解,主要的方法是使用FileOpenPickers。我仔细阅读了API's并试图获得最基本的,简单的,简单的FOP,我可以使其工作。

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应用程序开发时感到可怕而道歉。)任何建议,链接,鼓励都非常感激

以下是最新回报:

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

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

Microsoft Dev Center对此错误代码的帮助也不大。

修改

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

崩溃

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

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

1 个答案:

答案 0 :(得分:0)

你不能

根据the current limitations of the HoloLens shell,您无法使用内置的本机文件选择器(因为它不存在)。

  

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

     

Windows全息应用模型目前不公开文件系统的概念。有已知的文件夹,但没有内置的本地文件资源管理器应用程序,如Windows桌面或移动设备。应用可以将文件保存到其本地状态文件夹。应用程序还可以将文件保存到OneDrive等已注册的文件选择器应用程序。

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