Let’s say you want to access the filesystem in a Hololens app – e.g. to upload a video or picture from the camera roll to Azure. How would you do that?

As you’re building in fact a Universal Windows Platform (UWP) app, you have access to the UWP API’s (aka WinRT API’s) as well. You need to use the ENABLE_WINMD_SUPPORT flag for that code.

Add this to the usings:

#if ENABLE_WINMD_SUPPORT
using System;
using Windows.Storage;
#endif

In this case I’ve put the UWP code in a separate function. As most of the functions in UWP are asynchronous, it’s easier to make an async function to handle the await. In the function below I write the names of the files to a 3DText control stored in the DebugText public variable.

#if ENABLE_WINMD_SUPPORT
    private async void checkFiles()
    {
        if (DebugText != null)
        {
            DebugText.text = "CAMERA ROLL:\n";
            StorageFolder folder = KnownFolders.CameraRoll;
            IReadOnlyList<StorageFile> files = await folder.GetFilesAsync();
            if (files.Count == 0)
            {
                DebugText.text += "no files...?";
            }
            else
            {
                foreach (var file in files)
                {
                    DebugText.text += file.Name + "\n";
                }
            }
        }
    }
#endif

Now you can just call the function like this:

#if ENABLE_WINMD_SUPPORT
        checkFiles();
#endif

That’s it.