简体   繁体   English

无法访问 OneDrive 上的文件; HoloLens 运行时

[英]Can't access file on OneDrive; HoloLens runtime

I started working with the Microsoft HoloLens.我开始使用 Microsoft HoloLens。

I am completely new to C# programming.我对 C# 编程完全陌生。 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.我使用 Unity 2018.4.21f1 Visual Studio 2019 和已经提到的 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.我想编写一个打开 FileExplorer 的应用程序,我可以在其中 select OneDrive 从下拉菜单中选择 a.obj 文件(我们以 cube.obj 为例),这个文件在运行时得到处理和渲染。

Current behaviour:当前行为:

I can use a FileOpenPicker to select a file from OneDrive, but then the following error message appears:我可以使用 FileOpenPicker 来 select 来自 OneDrive 的文件,但随后出现以下错误消息:

Exception thrown at 0x76C330D2 in APP.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x0210C090.在 APP.exe 中的 0x76C330D2 处引发异常:Microsoft C++ 异常:Il2CppExceptionWrapper 在 memory 位置 0x0210C090。 DirectoryNotFoundException: Could not find a part of the path "C:\Data\Users\marcu\AppData\Local\Packages\microsoft.microsoftskydrive_8wekyb3d8bbwe\LocalState\OpenFile\cube.obj". DirectoryNotFoundException:找不到路径“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.如果 cube.obj 本地存储在 HoloLens 上,则一切正常。 So it could be related to the cloud based storage, but I can print the path, though.所以它可能与基于云的存储有关,但我可以打印路径。
  • Works with Unity Editor too.也适用于 Unity 编辑器。
  • The path is not longer than 260 signs.路径不超过 260 个标志。
  • 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.唯一的区别是我将带有 file.Path 的路径存储在一个字符串中。

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.如果有人有类似的问题并且可以帮助我解决这个问题或者可以给我一个提示,我将非常感激。

UWP apps can only access certain file system locations by default such as ApplicationData and Package.InstalledLocation . UWP 应用程序默认只能访问某些文件系统位置,例如ApplicationDataPackage.InstalledLocation Unfortunately, you cannot directly access the files in OneDrive through the path.遗憾的是,您无法通过该路径直接访问 OneDrive 中的文件。

But you can copy this file from OneDrive to ApplicationData.Current.LocalFolder by calling the method StorageFile.CopyAsync() .但是您可以通过调用StorageFile.CopyAsync()方法将此文件从 OneDrive 复制到ApplicationData.Current.LocalFolder 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.因为LocalFolder是你的应用可以自由存储数据的文件夹,在你的应用安装时创建,你可以通过字符串路径从LocalFolder访问这个文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM