How do I download files created by my own application deployed on HoloLens2 to my PC?

ymd._.ksyR 0 Reputation points
2023-01-17T12:27:15.7733333+00:00

I am a beginner in this field. I want to download a file generated by an application deployed on HoloLens2 to my PC. I found this URL1.

I tried to execute the source code of this URL1, but I could not figure out how to use the Windows.Storage class. Therefore, I tried to use the Windows Runtime API by referring to this URL2. The error in the function is gone, but I get the following error at using Windows.Storage in the console of Unity where I am developing HoloLens2.

The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)

When I type using Windows.Storage in the source code, the predictive conversion comes up.By the way, the predictive conversion of ENABLE_WINMD_SUPPORT in the source code of URL1 does not appear.

How can I solve this problem?

Thank you in advance.

Device used

Windows 10 Pro 21H2

Visual Studio 2019 16.11.18

Unity 2020.3.15f2

Universal Windows Platform (UWP)
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,239 questions
HoloLens Development
HoloLens Development
HoloLens: A family of Microsoft self-contained, holographic devices that enable engagement with digital content and interaction with holograms in the surrounding environment.Development: The process of researching, productizing, and refining new or existing technologies.
380 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rob Van Schooneveld 196 Reputation points Microsoft Employee
    2023-01-19T20:18:56.9+00:00

    Thanks for the follow up... You have a couple different questions here, and I'll do my best to answer them.

    Regarding accessing WinRT APIs in Unity, you will need to wrap them in the pre-processor directive in order not to see script errors. When you build the Universal Windows project type from the Unity Build settings, the flag will be set and your code will be included. For more information, you can refer to the Unity documentation here:

    Universal Windows Platform: WinRT API in C# scripts

    In general, you should consider writing your files to one of the known file locations / libraries:

    Files and folders in the Music, Pictures, and Videos libraries

    The question about accessing content on the device has a bit of a different answer. There are only two primary ways to connect into the device to access it:

    1. Using the Device Portal
    2. Connecting the device via USB

    When you connect via the device portal, you will have access to a bit more of the files on the device, specifically the content under AppData\Local\Packages<productname>\LocalState. So if you write to this path (similar to the Unity Player Log), you will need to utilize device portal to access it via a browser experience.

    When you connect via USB (and log into the device), we expose part of the storage via MTP (Media Transfer Protocol). This has a subset of the content that is available via device portal. The easiest way to access the content here is via File Explorer, and you would just need to ensure that you put the file in a known location as discussed in the article linked above.

    It would be possible if you wanted to programmatically access the content via an MTP client application. One way to do this would be via the Windows Media Device Manager SDK which is included as part of the standard Windows SDK:

    Windows Media Device Manager SDK

    However, this would not generally enable you to see additional file locations beyond what File Explorer would typically show you.

    1 person found this answer helpful.