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.
Use Environment.GetFolderPath(Environment.SpecialFolder.System);
, and for the program files folder use Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
.
Have a look at this link. Environment.GetEnvironmentVariable
hopefully, would do the job for you.
string systemDrive = Path.GetRoot(Environment.GetFolderPath(Environment.SpecialFolder.System));
string progamFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
精彩评论