dotnet/runtime

Directory path with special characters broken on MacOS Ventura 13.3.1

Open

#85.662 aperta il 2 mag 2023

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)C# (5445 fork)batch import
area-System.IOhelp wantedos-mac-os-x

Metriche repository

Star
 (17.886 star)
Metriche merge PR
 (Merge medio 12g 11h) (661 PR mergiate in 30 g)

Descrizione

Description

Creating a directory using Directory.CreateDirectory() and a string that contains special characters like ôé lead to wrong behavior on files inside it. For instance, opening and .docx or a .xlsx withing this folder won't work, instead you will arrive on Word / Excel home page as if the file were not found. However opening the file directly by selecting it from excel works fine. On top of that, the folder will have a blank file icon instead of the mac os default one.

Reproduction Steps

On MAC OS Ventura 13.3.1, create a console app from visual studio (.NET 7 for instance but it can be reproduced with all .NET framework versions).

Add the following line of code to create a folder on your desktop to the main and a txt file inside it:

var folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "testFôldér");

Directory.CreateDirectory(folderPath);

File.Create(Path.Combine(folderPath, "test.txt"));

Run the app.

Open the txt file inside the newly created folder. TextEdit will start but will fail to open the file you clicked on.

Now rename the folder on your Finder using right click rename and manually reenter the two accents.

Now double clicking on the text file works fine, TextEdit opens the file directly.

Expected behavior

Creating a folder using Directory.CreateDirectory() with accents characters within the name doesn't brake the path of contained files and applications like Excel / Word / TextEdit opens the file correctly when you double click on theme.

Actual behavior

Double clicking on a file withing a parent folder created with Directory.CreateDirectory() and accents inside the folderPath open the application concerned by the application but fails to open the file you double clicked on.

Regression?

This was working on previous MAC OS versions.

Known Workarounds

None

Configuration

Mac OS Ventura 13.3.1

.NET 7 (.NET framework 4.7.2 and .NET 6 have the same wrong behavior)

Other information

No response

Guida contributor