开发者

C# operating system installed directory

开发者 https://www.devze.com 2023-03-08 07:26 出处:网络
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.S

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消