jtth
jtth

Reputation: 886

Open local data path with FileOpenPicker

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

Upvotes: 0

Views: 1452

Answers (1)

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

Upvotes: 0

Related Questions