dotnet / dotnet/runtime

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

Open
#123,844 5 comments 0 reactions 0 assignees View on GitHub
area-System.Runtime help wanted
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.