.NET 8 for Macの特殊ディレクトリのパス
.NET 8 for MacではXamarin.Macの頃から微妙に戻り値が変わっています。
| SpecialFolder | .NET | Xamarin |
|---|---|---|
| Desktop | /Users/{ユーザー名}/Desktop | 同じ |
| Programs | ||
| MyDocuments | /Users/{ユーザー名}/Documents | /Users/{ユーザー} |
| MyDocuments | /Users/{ユーザー名}/Documents | /Users/{ユーザー} |
| Favorites | /Users/{ユーザー名}/Library/Favorites | 同じ |
| Startup | ||
| Recent | ||
| SendTo | ||
| StartMenu | ||
| MyMusic | /Users/{ユーザー名}/Music | 同じ |
| MyVideos | /Users/{ユーザー名}/Movies | /Users/{ユーザー}/Videos |
| DesktopDirectory | /Users/{ユーザー名}/Desktop | 同じ |
| MyComputer | ||
| NetworkShortcuts | ||
| Fonts | /Users/{ユーザー名}/Library/Fonts | 同じ |
| Templates | /Users/{ユーザー}/Templates | |
| CommonStartMenu | ||
| CommonPrograms | ||
| CommonStartup | ||
| CommonDesktopDirectory | ||
| ApplicationData | /Users/{ユーザー名}/Library/Application Support | /Users/{ユーザー}/.config |
| PrinterShortcuts | ||
| LocalApplicationData | /Users/{ユーザー名}/Library/Application Support | /Users/{ユーザー}/.local/share |
| InternetCache | /Users/{ユーザー名}/Library/Caches | 同じ |
| Cookies | ||
| History | ||
| CommonApplicationData | /usr/share | 同じ |
| Windows | ||
| System | /System | |
| ProgramFiles | /Applications | 同じ |
| MyPictures | /Users/{ユーザー名}/Pictures | 同じ |
| UserProfile | /Users/{ユーザー名} | 同じ |
| SystemX86 | ||
| ProgramFilesX86 | ||
| CommonProgramFiles | ||
| nProgramFilesX86 | ||
| CommonTemplates | /usr/share/templates | |
| CommonDocuments | ||
| CommonAdminTools | ||
| AdminTools | ||
| CommonMusic | ||
| CommonPictures | ||
| CommonVideos | ||
| Resources | ||
| LocalizedResources | ||
| CommonOemLinks | ||
| CDBurning |
MyDocumentsが「ホームディレクトリ直下」から「Documentsディレクトリ」に変更になっています。
ホームディレクトリはUserProfileで取得するようになりました。
MyVideoはVideosディレクトリからMoviesディレクトリになっています。
ApplicationDataと LocalApplicationDataは独自の隠しディレクトリからmacOSのルールに則った「~/Library/Application Support」になっています。
foreach (var folder in Enum.GetValues(typeof(Environment.SpecialFolder)))
{
var path = Environment.GetFolderPath((Environment.SpecialFolder)folder);
Console.WriteLine($"{folder} => {path}");
}