Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SHGetKnownFolderPath to get path to localappdata for current user #4998

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stevenbrix
Copy link

On Windows, it's not guaranteed that USERPROFILE is equivalent to %SYSTEMDRIVE%\Users\%USERNAME%. So it's possible that UserDefaults tries to write to a non-existent location, in which case it will never work. When this happens, all writes silently no-op.

This PR uses the Shell API SHGetKnownFolderPath to get the location of %LOCALAPPDATA% instead of manually building the path.

See documentation for this API:
image

Fixes #4997

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UserDefaults doesn't work on Windows when USERNAME and USERPROFILE don't match
2 participants