「.NET 8 for Macの特殊ディレクトリのパス」の版間の差分
Administrator (トーク | 投稿記録) ページの作成:「.NET 8 for MacではXamarin.Macの頃から微妙に戻り値が変わっています。xamarinでは「~/.local」などという独自の隠しディレクトリが使われていましたが、.NET for MacではmacOSのルールに則り「~/Library/Application Support」を返すようになったようです。 {| |+ ! Environment.SpecialFolder列挙体 !! Environment.GetFolderPathの戻り値 |- | Desktop || /Users/{ユーザー名}/Desktop |- | Programs ||…」 |
Administrator (トーク | 投稿記録) 編集の要約なし |
||
| (同じ利用者による、間の10版が非表示) | |||
| 1行目: | 1行目: | ||
.NET 8 for MacではXamarin. | .NET 8 for MacではXamarin.Macの頃から微妙に戻り値が変わっています。 | ||
.NET 6や.NET 7は試していません。 | |||
{| | {|class="wikitable sortable" style="overflow: auto;white-space: nowrap" | ||
|+ | |+ | ||
! | ! SpecialFolder !! .NET | ||
!Xamarin | |||
|- | |- | ||
| Desktop || /Users/{ユーザー名}/Desktop | | Desktop || /Users/{ユーザー名}/Desktop | ||
|同じ | |||
|- | |- | ||
| Programs || | | Programs || | ||
| | |||
|- | |- | ||
| MyDocuments || /Users/{ユーザー名}/Documents | | MyDocuments || /Users/{ユーザー名}/Documents | ||
|/Users/{ユーザー} | |||
|- | |- | ||
| MyDocuments || /Users/{ユーザー名}/Documents | | MyDocuments || /Users/{ユーザー名}/Documents | ||
|/Users/{ユーザー} | |||
|- | |- | ||
| Favorites || /Users/{ユーザー名}/Library/Favorites | | Favorites || /Users/{ユーザー名}/Library/Favorites | ||
|同じ | |||
|- | |- | ||
| Startup || | | Startup || | ||
| | |||
|- | |- | ||
| Recent || | | Recent || | ||
| | |||
|- | |- | ||
| SendTo || | | SendTo || | ||
| | |||
|- | |- | ||
| StartMenu || | | StartMenu || | ||
| | |||
|- | |- | ||
| MyMusic || /Users/{ユーザー名}/Music | | MyMusic || /Users/{ユーザー名}/Music | ||
|同じ | |||
|- | |- | ||
| MyVideos || /Users/{ユーザー名}/Movies | | MyVideos || /Users/{ユーザー名}/Movies | ||
|/Users/{ユーザー}/Videos | |||
|- | |- | ||
| DesktopDirectory || /Users/{ユーザー名}/Desktop | | DesktopDirectory || /Users/{ユーザー名}/Desktop | ||
|同じ | |||
|- | |- | ||
| MyComputer || | | MyComputer || | ||
| | |||
|- | |- | ||
| NetworkShortcuts || | | NetworkShortcuts || | ||
| | |||
|- | |- | ||
| Fonts || /Users/{ユーザー名}/Library/Fonts | | Fonts || /Users/{ユーザー名}/Library/Fonts | ||
|同じ | |||
|- | |- | ||
| Templates || | | Templates || | ||
|/Users/{ユーザー}/Templates | |||
|- | |- | ||
| CommonStartMenu || | | CommonStartMenu || | ||
| | |||
|- | |- | ||
| CommonPrograms || | | CommonPrograms || | ||
| | |||
|- | |- | ||
| CommonStartup || | | CommonStartup || | ||
| | |||
|- | |- | ||
| CommonDesktopDirectory || | | CommonDesktopDirectory || | ||
| | |||
|- | |- | ||
| ApplicationData || /Users/{ユーザー名}/Library/Application Support | | ApplicationData || /Users/{ユーザー名}/Library/Application Support | ||
|/Users/{ユーザー}/.config | |||
|- | |- | ||
| PrinterShortcuts || | | PrinterShortcuts || | ||
| | |||
|- | |- | ||
| LocalApplicationData || /Users/{ユーザー名}/Library/Application Support | | LocalApplicationData || /Users/{ユーザー名}/Library/Application Support | ||
|/Users/{ユーザー}/.local/share | |||
|- | |- | ||
| InternetCache || /Users/{ユーザー名}/Library/Caches | | InternetCache || /Users/{ユーザー名}/Library/Caches | ||
|同じ | |||
|- | |- | ||
| Cookies || | | Cookies || | ||
| | |||
|- | |- | ||
| History || | | History || | ||
| | |||
|- | |- | ||
| CommonApplicationData || /usr/share | | CommonApplicationData || /usr/share | ||
|同じ | |||
|- | |- | ||
| Windows || | | Windows || | ||
| | |||
|- | |- | ||
| System || /System | | System || /System | ||
| | |||
|- | |- | ||
| ProgramFiles || /Applications | | ProgramFiles || /Applications | ||
|同じ | |||
|- | |- | ||
| MyPictures || /Users/{ユーザー名}/Pictures | | MyPictures || /Users/{ユーザー名}/Pictures | ||
|同じ | |||
|- | |- | ||
| UserProfile || /Users/{ユーザー名} | | UserProfile || /Users/{ユーザー名} | ||
|同じ | |||
|- | |- | ||
| SystemX86 || | | SystemX86 || | ||
| | |||
|- | |- | ||
| ProgramFilesX86 || | | ProgramFilesX86 || | ||
| | |||
|- | |- | ||
| CommonProgramFiles || | | CommonProgramFiles || | ||
| | |||
|- | |- | ||
|nProgramFilesX86 || | |nProgramFilesX86 || | ||
| | |||
|- | |- | ||
| CommonTemplates || | | CommonTemplates || | ||
|/usr/share/templates | |||
|- | |- | ||
| CommonDocuments || | | CommonDocuments || | ||
| | |||
|- | |- | ||
| CommonAdminTools || | | CommonAdminTools || | ||
| | |||
|- | |- | ||
| AdminTools || | | AdminTools || | ||
| | |||
|- | |- | ||
| CommonMusic || | | CommonMusic || | ||
| | |||
|- | |- | ||
| CommonPictures || | | CommonPictures || | ||
| | |||
|- | |- | ||
| CommonVideos || | | CommonVideos || | ||
| | |||
|- | |- | ||
| Resources || | | Resources || | ||
| | |||
|- | |- | ||
| LocalizedResources || | | LocalizedResources || | ||
| | |||
|- | |- | ||
| CommonOemLinks || | | CommonOemLinks || | ||
| | |||
|- | |- | ||
| CDBurning || | | CDBurning || | ||
| | |||
|} | |} | ||
[[category: .NET]] | == 解説 == | ||
MyDocumentsが「ホームディレクトリ直下」から「Documentsディレクトリ」に変更になっています。 | |||
ホームディレクトリはUserProfileで取得するようになりました。 | |||
MyVideoはVideosディレクトリからMoviesディレクトリになっています。 | |||
ApplicationDataと LocalApplicationDataは独自の隠しディレクトリからmacOSのルールに則った「~/Library/Application Support」になっています。 | |||
TemplatesとCommonTemplatesは何も返さなくなっています。 | |||
== コード == | |||
<source lang=csharp> | |||
foreach (var folder in Enum.GetValues(typeof(Environment.SpecialFolder))) | |||
{ | |||
var path = Environment.GetFolderPath((Environment.SpecialFolder)folder); | |||
Console.WriteLine($"{folder} => {path}"); | |||
} | |||
</source> | |||
== 関連項目 == | |||
* [[.NET 8 for Androidの特殊ディレクトリのパス]] | |||
[[category: .NET for Mac]] | |||
2024年10月21日 (月) 06:10時点における最新版
.NET 8 for MacではXamarin.Macの頃から微妙に戻り値が変わっています。 .NET 6や.NET 7は試していません。
| 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」になっています。
TemplatesとCommonTemplatesは何も返さなくなっています。
コード[編集 | ソースを編集]
foreach (var folder in Enum.GetValues(typeof(Environment.SpecialFolder)))
{
var path = Environment.GetFolderPath((Environment.SpecialFolder)folder);
Console.WriteLine($"{folder} => {path}");
}