How do I find the drive, using C#, in which I installed the operating system (say, Windows 7)? Then I have to get the Program Files directory.
Asked
Active
Viewed 2,313 times
0
-
see http://stackoverflow.com/questions/194157/c-how-to-get-program-files-x86-on-vista-x64 for an example on Vista – Marijn May 26 '11 at 10:02
3 Answers
4
Use Environment.GetFolderPath(Environment.SpecialFolder.System);, and for the program files folder use Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);.
Peter Mortensen
- 30,030
- 21
- 100
- 124
Leon Tayson
- 4,455
- 7
- 34
- 35
1
Have a look at this link. Environment.GetEnvironmentVariable hopefully, would do the job for you.
Community
- 1
- 1
FIre Panda
- 6,351
- 2
- 24
- 37
1
string systemDrive = Path.GetRoot(Environment.GetFolderPath(Environment.SpecialFolder.System));
string progamFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
Guillaume
- 12,509
- 3
- 38
- 47