//方法一:使用 Environment.SpecialFolder 列舉常數來取得
Console.WriteLine("[Desktop]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
Console.WriteLine("[Programs]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.Programs));
Console.WriteLine("[Personal]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.Personal));
Console.WriteLine("[MyDocuments]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
Console.WriteLine("[Favorites]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites));
Console.WriteLine("[Startup]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.Startup));
Console.WriteLine("[Recent]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.Recent));
Console.WriteLine("[SendTo]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.SendTo));
Console.WriteLine("[StartMenu]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu));
Console.WriteLine("[MyMusic]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.MyMusic));
Console.WriteLine("[DesktopDirectory]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
Console.WriteLine("[MyComputer]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.MyComputer));
Console.WriteLine("[Templates]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.Templates));
Console.WriteLine("[ApplicationData]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
Console.WriteLine("[LocalApplicationData]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
Console.WriteLine("[InternetCache]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
Console.WriteLine("[Cookies]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.Cookies));
Console.WriteLine("[History]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.History));
Console.WriteLine("[CommonApplicationData]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));
Console.WriteLine("[System]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.System));
Console.WriteLine("[ProgramFiles]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
Console.WriteLine("[MyPictures]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures));
Console.WriteLine("[CommonProgramFiles]\r\n{0}",
System.Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles));
//方法二:使用環境變數來取得
Console.WriteLine("[%USERPROFILE%]\r\n{0}",
System.Environment.GetEnvironmentVariable("USERPROFILE"));