簡體   English   中英

C#操作系統安裝目錄

[英]C# operating system installed directory

如何使用 C# 找到驅動器,我在其中安裝了操作系統(例如 Windows 7)? 然后我必須獲取 Program Files 目錄。

使用Environment.GetFolderPath(Environment.SpecialFolder.System); , 對於程序文件文件夾使用Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); .

看看這個鏈接 Environment.GetEnvironmentVariable希望能為您完成這項工作。

string systemDrive = Path.GetRoot(Environment.GetFolderPath(Environment.SpecialFolder.System));
string progamFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM