Skip to content

Specialfolder.MyDocuments returns localized name for folder instead of actual folder name on windows. #123844

@zaphod77

Description

@zaphod77

Description

When using Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), the name of the documents folder is localized is sometimes returned, when the actual full path shold be what's returned.

Reproduction Steps

  1. have documents folder redirected to onedrive.
  2. have multibyte characters in the localized name
  3. use Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) to fetch the path.

Expected behavior

It should return the actual and correct full utf-16 path to MyDocuments specialfolder into the .net string, ready for use

Actual behavior

Instead, you get the localized folder name from the desktop.ini present in the folder, and, at least if it's Cyrillic, the backslash before the folder name disappears.

Regression?

It probably is a regression, but i have no idea when it started, so that doesnt' matter.

Known Workarounds

Actually read the windows environment variables directly and fetch the real path that way.

Configuration

.NET 9.0.10

Windows 11 x64

I believe this affects all version of windows that have the localized folder names feature.

Other information

app showing the bug is here.

https://github.com/tsunamods-codes/7th-Heaven

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions