开发者

C# operating system installed directory

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜