2011-05-26 153 views
0

如何找到使用C#的驱动器,在该驱动器中安装了操作系统(比如Windows 7)?然后我必须得到Program Files目录。C#操作系统安装目录

+0

有关Vista上的示例,请参阅http://stackoverflow.com/questions/194157/c-how-to-get-program-files-x86-on-vista-x64 – Marijn 2011-05-26 10:02:54

回答

4

使用Environment.GetFolderPath(Environment.SpecialFolder.System);,而对于程序文件文件夹使用Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

1

看看这个link。希望能为你做好这项工作。

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