Getting special folder path via .NET for HoloLens App

Summary

When special folder paths on the HoloLens app that is a UWP app, .NET developers can use Environment.SpecialFolder and Windows.Storage namespace.

  1. Environment.SpecialFolder Enum (System) | Microsoft Docs
  2. Windows.Storage Namespace - Windows UWP applications | Microsoft Docs

This post describes the results of actually running the application on HoloLens 2 and logging folder paths. Please note that the results doesn't include reading or writing files from the folder.

Scope

  1. Environment.SpecialFolder
  2. Windows.Storage.ApplicationData
  3. Windows.Storage.KnownFolders
  4. Windows.Storage.SystemDataPaths
  5. Windows.Storage.UserDataPaths

Prerequisites

  • HoloLens 2 (Windows Holographic v21H2)
  • Windows 10 v21H2
  • Unity 2020.3.29f1
  • Visual Studio 2019 v16.11.10

Path

Environment.SpecialFolder

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\AppData\Roaming

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\AppData\Local\Packages\Template3D_pzq3xp76mxafg\RoamingState

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\AppData\Local\Packages\b0c4f284-b01c-4ec0-a3c9-af917af79727_bkv2wzhfgj7e0\LocalState

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\AppData\Local\Packages\Template3D_pzq3xp76mxafg\LocalState

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\AppData\Local\Packages\b0c4f284-b01c-4ec0-a3c9-af917af79727_bkv2wzhfgj7e0\LocalState\ProgramData

// HoloLens 2 (Windows Holographic)
System.UnauthorizedAccessException: Failed getting the path of a special folder: Access Denied.

Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Documents

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\Documents

Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Pictures

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\Pictures

Environment.GetFolderPath(Environment.SpecialFolder.MyVideos)

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Videos

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\Videos

Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)

1
2
3
4
5
// PC (Windows 10)
C:\\Users\Public\Documents

// HoloLens 2 (Windows Holographic)
System.UnauthorizedAccessException: Failed getting the path of a special folder: Access Denied.

Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures)

1
2
3
4
5
// PC (Windows 10)
C:\\Users\Public\Pictures

// HoloLens 2 (Windows Holographic)
System.UnauthorizedAccessException: Failed getting the path of a special folder: Access Denied.

Environment.GetFolderPath(Environment.SpecialFolder.CommonVideos)

1
2
3
4
5
// PC (Windows 10)
C:\\Users\Public\Videos

// HoloLens 2 (Windows Holographic)
System.UnauthorizedAccessException: Failed getting the path of a special folder: Access Denied.

Windows.Storage.ApplicationData

Windows.Storage.ApplicationData.Current.LocalCacheFolder.Path

1
2
3
4
5
// PC (Windows 10)
C:\Users\hiroakit\AppData\Local\Packages\b0c4f284-b01c-4ec0-a3c9-af917af79727_bkv2wzhfgj7e0\LocalCache

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\AppData\Local\Packages\Template3D_pzq3xp76mxafg\LocalCache

Windows.Storage.ApplicationData.Current.LocalFolder.Path

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\AppData\Local\Packages\b0c4f284-b01c-4ec0-a3c9-af917af79727_bkv2wzhfgj7e0\LocalState

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\AppData\Local\Packages\Template3D_pzq3xp76mxafg\LocalState

Windows.Storage.ApplicationData.Current.RoamingFolder.Path

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\AppData\Local\Packages\b0c4f284-b01c-4ec0-a3c9-af917af79727_bkv2wzhfgj7e0\RoamingState

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\AppData\Local\Packages\Template3D_pzq3xp76mxafg\RoamingState

Windows.Storage.ApplicationData.Current.SharedLocalFolder.Path

1
2
3
4
5
// PC (Windows 10)
C:\\ProgramData\Microsoft\Windows\AppRepository\Families\b0c4f284-b01c-4ec0-a3c9-af917af79727_bkv2wzhfgj7e0\SharedLocal

// HoloLens 2 (Windows Holographic)
System.NullReferenceException: Object reference not set to an instance of an object.

Windows.Storage.ApplicationData.Current.TemporaryFolder.Path

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\AppData\Local\Packages\b0c4f284-b01c-4ec0-a3c9-af917af79727_bkv2wzhfgj7e0\TempState

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\AppData\Local\Packages\Template3D_pzq3xp76mxafg\TempState

Windows.Storage.KnownFolders

Windows.Storage.KnownFolders.AppCaptures.Path

Required Video Library capability, if it isn't you will get Attempted to perform an unauthorized operation.

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Videos\Captures

// HoloLens 2 (Windows Holographic)
C:\Data\USERS\hiroakit\Videos\Captures

Windows.Storage.KnownFolders.CameraRoll.Path

Required Picture Library capability, if it isn't you will get Attempted to perform an unauthorized operation.

1
2
3
4
5
// PC (Windows 10)
C:\\Users\\hiroakit\Pictures\Camera Roll

// HoloLens 2 (Windows Holographic)
C:\Data\USERS\hiroakit\Pictures\Camera Roll

Windows.Storage.KnownFolders.DocumentsLibrary.Path

Required Documents Library capability, if it isn't you will get Attempted to perform an unauthorized operation.

1
2
3
4
5
// PC (Windows 10)
"" // string.Empty;

// HoloLens 2 (Windows Holographic)
"" // string.Empty;

Windows.Storage.KnownFolders.HomeGroup.Path

1
2
3
4
5
// PC (Windows 10)
Cannot access Homegroup. Homegroup may not be set up or may have encountered an error.

// HoloLens 2 (Windows Holographic)
Cannot access Homegroup. Homegroup may not be set up or may have encountered an error.

Windows.Storage.KnownFolders.Objects3D.Path

Required 3D Object capability, if it isn't you will get Attempted to perform an unauthorized operation.

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\3D Objects

// HoloLens 2 (Windows Holographic)
C:\Data\USERS\hiroakit\3D Objects

Windows.Storage.KnownFolders.PicturesLibrary.Path

Required Picture Library capability, if it isn't you will get Attempted to perform an unauthorized operation.

1
2
3
4
5
// PC (Windows 10)
"" // string.Empty;

// HoloLens 2 (Windows Holographic)
"" // string.Empty;

Windows.Storage.KnownFolders.SavedPictures.Path

Required Picture Library capability, if it isn't you will get Attempted to perform an unauthorized operation.

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Pictures\Saved Pictures

// HoloLens 2 (Windows Holographic)
C:\Data\USERS\hiroakit\Pictures\Saved Pictures\Template3D_pzq3xp76mxafg!App

Windows.Storage.KnownFolders.VideosLibrary.Path

Required Video Library capability, if it isn't you will get Attempted to perform an unauthorized operation.

1
2
3
4
5
// PC (Windows 10)
"" // string.Empty;

// HoloLens 2 (Windows Holographic)
"" // string.Empty;

Windows.Storage.SystemDataPaths

Windows.Storage.SystemDataPaths.GetDefault().Public

1
2
3
4
5
// PC (Windows 10)
C:\Users\Public

// HoloLens 2 (Windows Holographic)
U:\Users\Public

Windows.Storage.SystemDataPaths.GetDefault().PublicDocuments

1
2
3
4
5
// PC (Windows 10)
C:\Users\Public\Documents

// HoloLens 2 (Windows Holographic)
U:\Users\Public\Documents

Windows.Storage.SystemDataPaths.GetDefault().PublicDownloads

1
2
3
4
5
// PC (Windows 10)
C:\Users\Public\Downloads

// HoloLens 2 (Windows Holographic)
U:\Users\Public\Downloads

Windows.Storage.SystemDataPaths.GetDefault().PublicPictures

1
2
3
4
5
// PC (Windows 10)
C:\Users\Public\Pictures

// HoloLens 2 (Windows Holographic)
U:\Users\Public\Pictures

Windows.Storage.SystemDataPaths.GetDefault().PublicVideos

1
2
3
4
5
// PC (Windows 10)
C:\Users\Public\Videos

// HoloLens 2 (Windows Holographic)
U:\Users\Public\Videos

Windows.Storage.UserDataPaths

Windows.Storage.UserDataPaths.GetDefault().CameraRoll

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Pictures\Screenshots

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\Pictures\Camera Roll

Windows.Storage.UserDataPaths.GetDefault().Documents

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Documents

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\Documents

Windows.Storage.UserDataPaths.GetDefault().Downloads

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Downloads

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\Downloads

Windows.Storage.UserDataPaths.GetDefault().LocalAppData

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\AppData\Local

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\AppData\Local

Windows.Storage.UserDataPaths.GetDefault().LocalAppDataLow

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\AppData\LocalLow

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\AppData\LocalLow

Windows.Storage.UserDataPaths.GetDefault().Pictures

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Pictures

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\Pictures

Windows.Storage.UserDataPaths.GetDefault().RoamingAppData

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\AppData\Roaming

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\AppData\Roaming

Windows.Storage.UserDataPaths.GetDefault().SavedPictures

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Pictures\Saved Pictures

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\Pictures\Saved Pictures

Windows.Storage.UserDataPaths.GetDefault().Screenshots

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\Pictures\Screenshots

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\Pictures\Screenshots

Windows.Storage.UserDataPaths.GetDefault().Videos

1
2
3
4
5
// PC (Windows 10)
C:\\Users\Public\Videos

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\Videos

Other

Path.GetTempPath()

1
2
3
4
5
// PC (Windows 10)
C:\\Users\hiroakit\AppData\Local\Packages\b0c4f284-b01c-4ec0-a3c9-af917af79727_bkv2wzhfgj7e0\AC\Temp\

// HoloLens 2 (Windows Holographic)
C:\Data\Users\hiroakit\AppData\Local\Packages\template3d_pzq3xp76mxafg\AC\Temp\

System.Reflection.Assembly.GetExecutingAssembly().Location

1
2
3
4
5
// PC (Windows 10)
C:\\work\UWPApp\UWPApp\bin\x86\Debug\AppX\entrypoint\UWPApp.exe

// HoloLens 2 (Windows Holographic)
"" // string.Empty;