C#:擷取Windows系統特殊檔案夾的路徑

來源:互聯網
上載者:User

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")

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.