ryota2357

[C#] MacOSにおける Environment.GetFolderPath(Environment.SpecialFolder)

投稿日:

C#

Environment.GetFolderPath Methodというメソッドがある。

Gets the path to the system special folder that is identified by the specified enumeration.

指定された列挙型で識別されるシステム特殊フォルダのパスを取得する。(DeepL)

このメソッドの引数はEnvironment.SpecialFolder Enumである。

「こいつら、MacOS だとどうなるのだろうか?」ってことで調べた(全部実行してみた)のでその結果。

環境

「実行したらこうなったよ」なので環境依存の可能性大。ドキュメントとしてどこかに書いてあるのだろうか?

  • MacOS 12.5
  • MacBook Pro (14 インチ、2021)
  • チップ: Apple M1 Pro
  • .Net: 6.0.302 (dotnet --version)

結果

以下のようなスクリプトを実行した結果。
オプションに DoNotVerify を設定しているので、すでに存在するかどうかは考慮してない。

Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.Cookies, Environment.SpecialFolderOption.DoNotVerify));

出力に $HOME って書いてるけど、実際はそれも展開されて出力されてる。「ー」は空行が出力されたもの。

SpecialFolder出力
Cookiesー
Desktop$HOME/Desktop
Favorites$HOME/Library/Favorites
Fonts$HOME/Library/Fonts
Historyー
Personal$HOME
Programsー
Recentー
Resourcesー
Startupー
System/System
Templates$HOME/Templates
Windowsー
AdminToolsー
ApplicationData$HOME/.config
CommonDocumentsー
CommonMusicー
CommonPicturesー
CommonProgramsー
CommonStartupー
CommonTemplates/usr/share/templates
CommonVideosー
DesktopDirectory$HOME/Desktop
InternetCache$HOME/Library/Caches
LocalizedResourcesー
MyComputerー
MyDocuments$HOME
MyMusic$HOME/Music
MyPictures$HOME/Pictures
MyVideos$HOME/Videos
NetworkShortcutsー
PrinterShortcutsー
ProgramFiles/Applications
SendToー
StartMenuー
SystemX86ー
UserProfile$HOME
CDBurningー
CommonAdminToolsー
CommonApplicationData/usr/share
CommonDesktopDirectoryー
CommonOemLinksー
CommonProgramFilesー
CommonStartMenuー
LocalApplicationData$HOME/.local/share
ProgramFilesX86ー
CommonProgramFilesX86ー