Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Fix log folder generation failing with UnauthorizedAccessError on UWP #390

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

NoTuxNoBux
Copy link

This happens immediately on startup, even if nothing is logged, because the folders are created and their path is inside the application directory in e.g. Data/Logs, which is read-only for security reasons on UWP - and will likely also be read-only when an app is installed versions on Linux distributions.

The exact error is:

UnauthorizedAccessException: Access to the path "C:/data/Programs/WindowsApps/unity-app_1.0.0.0_foo_abcdefghijk/Data/Logs" is denied.`

System.IO.Directory.CreateDirectoriesInternal (System.String path) <...>
System.IO.Directory.CreateDirectory (System.String path) <...>
BMSLogger.Init () <...>

This changes the path to use the persistent data path, which is writable, and on Windows something like LocalAppData\unity-app_1.0.0.0_foo__abcdefghijk\LocalState\Logs\bmslog.txt.

This happens because the path is inside the application directory in
e.g. "Data/Logs", which is read-only for security reasons on UWP - and
will likely also be read-only when an app is installed versions on Linux
distributions.

The exact error is:

```
UnauthorizedAccessException: Access to the path "C:/data/Programs/WindowsApps/unity-app_1.0.0.0_foo_abcdefghijk/Data/Logs" is denied.`

System.IO.Directory.CreateDirectoriesInternal (System.String path) <...>
System.IO.Directory.CreateDirectory (System.String path) <...>
BMSLogger.Init () <...>
```

This changes the path to use the persistent data path, which is
writable, and on Windows something like
`LocalAppData\unity-app_1.0.0.0_foo__abcdefghijk\LocalState\Logs\bmslog.txt`.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant