The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Unity - FileOpenPicker causes crash
In my hololens application I am trying to load a single file from onedrive. I tried to use the fileopenpicker however when I deploy my app to hololens and call the OpenFileAsync function as UnityEngine.WSA.Application.InvokeOnUIThread(()=> OpenFileAsync(), false); my app crashes and Visual Studio gives 0xc000027b error code. I tried many samples on the internet yet non of them did work. I don't know what I'm missing. Any help would be appreciated. Here is my code:
using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using System; using UnityEngine.WSA; using UnityEngine.UI; #if ENABLE_WINMD_SUPPORT using Windows.Storage; using Windows.Storage.Streams; using Windows.Storage.Pickers; #endif public class GetFile : MonoBehaviour { public TextMesh label; #if !UNITY_EDITOR private FileOpenPicker openPicker; #endif public void CallFile() { #if !UNITY_EDITOR UnityEngine.WSA.Application.InvokeOnUIThread(()=> OpenFileAsync(), false); #endif } #if !UNITY_EDITOR private async void OpenFileAsync() { FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; openPicker.FileTypeFilter.Add(".txt"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null) { // Application now has read/write access to the file label.text = "find"; } else { label.text = "nope"; } } #endif }
Best Answer
-
Optionsmark_grossnickle ✭✭✭
Maybe add a try catch around the thread and in the thread and see if you can catch the actual error?
It could be PickerLocationId.DocumentsLibrary. You'll need to make sure you are using a location that you have the rights to access. Check your Player Settings/Publishing Settings/Capabilities to enable the folders you need. I am not sure which one is documents but there are things like MusicLibrary and PicturesLibrary. Perhaps check PicturesLibrary and then change PickerLocationId to your picture library folder just to make sure it is not a permissions issue.
Taqtile
5
Answers
Maybe add a try catch around the thread and in the thread and see if you can catch the actual error?
It could be PickerLocationId.DocumentsLibrary. You'll need to make sure you are using a location that you have the rights to access. Check your Player Settings/Publishing Settings/Capabilities to enable the folders you need. I am not sure which one is documents but there are things like MusicLibrary and PicturesLibrary. Perhaps check PicturesLibrary and then change PickerLocationId to your picture library folder just to make sure it is not a permissions issue.
Taqtile
It may be worth upgrading to RS5 and checking out how they do the file picker without leaving the app:
https://forums.hololens.com/discussion/10872/announcing-hololens-preview-17720#latest
Taqtile
Thanks for your answer. Turning on the pictureslibrary capability and changing the suggested start location to pictureslibrary did the job. However it's not clear how to give permisssion access to -for example- documents folder. Its weird that I can start from the pictures folder and navigate back to where I want but when I want to directly go to the folder I want, the app just crashes and I can't catch the error even with try-catch block.
Hi modsimmer I needed to do the same thing.. I was wondering if you could share the code you used to load files from one drive ?