1

I started working with the Microsoft HoloLens.

I am completely new to C# programming. So this could be a simple or even stupid question, but I just can't explain it and couldn't find any information about it. I work with Unity 2018.4.21f1 Visual Studio 2019 and the already mentioned HoloLens.

Desired behaviour:

I would like to program an app that opens a FileExplorer where I can select OneDrive from the drop down menu, choose a .obj-file (let's take cube.obj as an example) and this file gets processed and rendered at runtime.

Current behaviour:

I can use a FileOpenPicker to select a file from OneDrive, but then the following error message appears:

Exception thrown at 0x76C330D2 in APP.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x0210C090. DirectoryNotFoundException: Could not find a part of the path "C:\Data\Users\marcu\AppData\Local\Packages\microsoft.microsoftskydrive_8wekyb3d8bbwe\LocalState\OpenFile\cube.obj".

Notes:

  • Everything works perfectly fine if cube.obj is stored locally on the HoloLens. So it could be related to the cloud based storage, but I can print the path, though.
  • Works with Unity Editor too.
  • The path is not longer than 260 signs.
  • There are no spaces in the path.
  • Maybe I just lack the appropriate search syntax to find the answer.
  • Unfortunately, searching the error code was not helpful.
  • I can also add a code snippet, but in principle it is very similar to the first example from here. The only difference is that I store the path with file.Path in a string.

If someone had a similar problem and could help me to solve this one or could give me a hint, I would be very grateful.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • https://stackoverflow.com/questions/51383441/using-onedrive-filepicker-to-access-data have a look at this – Ryan McDonough Apr 15 '20 at 08:36
  • @RyanMcDonough: Hi, I have already seen the page and looked at the information it contains. However, I would like to get it running without a external asset. I also have checked the provided links. These seem to be about the FileExplorer as such, which works for me in principle. Or am I wrong? But thanks for the answer – man_with_finite_freetime Apr 15 '20 at 09:39
  • We try to use FileOpenPicker to select a file from OneDrive on HoloLens1, It can select and download files as excepted,so the issue should have nothing to do with FileOpenPicker. When you get the instance of the class StorageFile, the method PickSingleFileAsync is done. So the error may have occurred when you tried to read the file. Can you provide any code about this? – Hernando - MSFT Apr 17 '20 at 07:37
  • Besides, this reference will help you understand the File access permissions: https://learn.microsoft.com/en-us/windows/uwp/files/file-access-permissions And to access OneDrive you need to add File Type Associations to your app manifest that declare specific file types that your app can access in this location: https://learn.microsoft.com/en-us/windows/uwp/files/file-access-permissions#accessing-additional-locations – Hernando - MSFT Apr 17 '20 at 07:38
  • @Hernando-MSFT: Thx for the information. You are probably correct about the "has nothing to do with FileOpenPicker"-part. While creating a code snippet I noticed that the error occurs only when I call the obj.-converter with `Mesh mesh = Instantiate(GetComponent().Model(path)) as Mesh;` So the problem is apparently in the `ObjFileLoader.cs` script. Which doesn't help me at all right now ^^ I will go through the code once more and try to figure it out. One thing, that bugs me still is that it works perfectly fine if i try it with a locally saved obj-file. – man_with_finite_freetime Apr 17 '20 at 10:30

1 Answers1

0

UWP apps can only access certain file system locations by default such as ApplicationData and Package.InstalledLocation. Unfortunately, you cannot directly access the files in OneDrive through the path.

But you can copy this file from OneDrive to ApplicationData.Current.LocalFolder by calling the method StorageFile.CopyAsync(). Because the LocalFolder is the folder where your app can store data freely and be created when your app is installed, you can access this file from LocalFolder by the string path.

Hernando - MSFT
  • 2,895
  • 1
  • 5
  • 11
  • Thanks for the info, I figured as much. I already looked at the workaround with the copying of the data and will continue to use it. The answer was accepted. Thank you again. A little bit off topic: Can anyone tell me why there are such strong restrictions on data access on the HoloLens? (just curious) – man_with_finite_freetime Apr 21 '20 at 07:58