Environment.GetFolderPath 方法
擷取指向由指定枚舉標識的系統特殊檔案夾的路徑。
命名空間:System
public static string GetFolderPath (
SpecialFolder folder
)
參數
folder
標識系統特殊檔案夾的枚舉常數。
傳回值
如果指定系統的特殊檔案夾實際存在於您的電腦上,則為到該檔案夾的路徑;否則為空白字串 ("")。 如果系統未建立檔案夾、已刪除現有檔案夾,或者檔案夾是不對應實體路徑的虛擬目錄(例如“我的電腦”),則該檔案夾不會實際存在。
主要用到的相關內容是:
Environment.GetFolderPath 方法
Environment.SpecialFolder 枚舉
枚舉包括了很多成員,具體的請參閱MSDN中的相關項目。
Environment.GetFolderPath(Environment.SpecialFolder.Favorites); //擷取用作使用者收藏夾項的公用儲存庫的目錄。
Environment.GetFolderPath(Environment.SpecialFolder.History); //擷取用作 Internet 記錄項的公用儲存庫的目錄。
Environment.GetFolderPath(Environment.SpecialFolder.Startup); //擷取對應於使用者的“啟動”程式組的目錄。
其他資訊:
System.Environment.GetEnvironmentVariable("OS");
System.Environment.GetEnvironmentVariable("TEMP");
System.Environment.GetEnvironmentVariable("WINDIR");
System.Environment.SystemDirectory;
System.Environment.UserDomainName;
System.Environment.WorkingSet;
System.Environment.GetEnvironmentVariable("ComputerName")