0

/Data/myFiles/

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();

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

Here is the latest return:

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

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

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

EDIT:

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

Crashes with

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

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

jtth
  • 876
  • 1
  • 12
  • 40
  • Well, if you are picking a file, presumably it is because you NEED the file, so why use async? – JuanR Jun 30 '17 at 15:44
  • @Juan All the documentation I've found using file pickers uses await and async. Please explain how to use w/o if that's what you're implying. And yes I do need the file – jtth Jun 30 '17 at 15:46
  • I assume you are executing this as part of a click event or something, right? That method is most likely already marked as async, so there is no need to wrap the execution with a task. Remove the sorrounding Task and just execute the code normally. The PickSingleFileAsync() is already async. – JuanR Jun 30 '17 at 15:57
  • @Juan Please see edit. Removed task/async wrap, same error. – jtth Jun 30 '17 at 16:07

1 Answers1

0

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

File Explorer and Local File System

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.

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

Community
  • 1
  • 1