.NET Framework 存取系統特殊資料夾 (Environment SpecialFolder)
2021-02-09
筆記如何使用 System Class 中的 Environment 存取系統特殊資料夾。
說明
var specialFolder = Enum.GetValues(typeof(System.Environment.SpecialFolder));
foreach (System.Environment.SpecialFolder folder in specialFolder)
{
Console.WriteLine($"{folder} : {(int)folder} \n
{Environment.GetFolderPath(folder)}");
}
Desktop : 0
C:\Users\sdwh\Desktop
Programs : 2
C:\Users\sdwh\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
MyDocuments : 5
C:\Users\sdwh\Documents
MyDocuments : 5
C:\Users\sdwh\Documents
Favorites : 6
C:\Users\sdwh\Favorites
Startup : 7
C:\Users\sdwh\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Recent : 8
C:\Users\sdwh\AppData\Roaming\Microsoft\Windows\Recent
SendTo : 9
C:\Users\sdwh\AppData\Roaming\Microsoft\Windows\SendTo
StartMenu : 11
C:\Users\sdwh\AppData\Roaming\Microsoft\Windows\Start Menu
MyMusic : 13
C:\Users\sdwh\Music
MyVideos : 14
C:\Users\sdwh\Videos
DesktopDirectory : 16
C:\Users\sdwh\Desktop
MyComputer : 17
NetworkShortcuts : 19
C:\Users\sdwh\AppData\Roaming\Microsoft\Windows\Network Shortcuts
Fonts : 20
C:\Windows\Fonts
Templates : 21
C:\Users\sdwh\AppData\Roaming\Microsoft\Windows\Templates
CommonStartMenu : 22
C:\ProgramData\Microsoft\Windows\Start Menu
CommonPrograms : 23
C:\ProgramData\Microsoft\Windows\Start Menu\Programs
CommonStartup : 24
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
CommonDesktopDirectory : 25
C:\Users\Public\Desktop
ApplicationData : 26
C:\Users\sdwh\AppData\Roaming
PrinterShortcuts : 27
C:\Users\sdwh\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
LocalApplicationData : 28
C:\Users\sdwh\AppData\Local
InternetCache : 32
C:\Users\sdwh\AppData\Local\Microsoft\Windows\INetCache
Cookies : 33
C:\Users\sdwh\AppData\Local\Microsoft\Windows\INetCookies
History : 34
C:\Users\sdwh\AppData\Local\Microsoft\Windows\History
CommonApplicationData : 35
C:\ProgramData
Windows : 36
C:\Windows
System : 37
C:\Windows\system32
ProgramFiles : 38
C:\Program Files (x86)
MyPictures : 39
C:\Users\sdwh\Pictures
UserProfile : 40
C:\Users\sdwh
SystemX86 : 41
C:\Windows\SysWOW64
ProgramFilesX86 : 42
C:\Program Files (x86)
CommonProgramFiles : 43
C:\Program Files (x86)\Common Files
CommonProgramFilesX86 : 44
C:\Program Files (x86)\Common Files
CommonTemplates : 45
C:\ProgramData\Microsoft\Windows\Templates
CommonDocuments : 46
C:\Users\Public\Documents
CommonAdminTools : 47
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools
AdminTools : 48
C:\Users\sdwh\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools
CommonMusic : 53
C:\Users\Public\Music
CommonPictures : 54
C:\Users\Public\Pictures
CommonVideos : 55
C:\Users\Public\Videos
Resources : 56
C:\Windows\resources
LocalizedResources : 57
CDBurning : 59
C:\Users\sdwh\AppData\Local\Microsoft\Windows\Burn\Burn