How to get the name of the drive that the OS is installed on?

前端 未结 3 1759
一向
一向 2020-12-11 15:59

In C#, how do I get the name of the drive that the Operating System is installed on?

相关标签:
3条回答
  • 2020-12-11 16:31

    There is an enum "SpecialFolder" in Environment where we can select the folder we are looking for..

    Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

    0 讨论(0)
  • 2020-12-11 16:35

    All other Environment properties can be found at ms itself : http://msdn.microsoft.com/en-us/library/system.environment_properties.aspx

    SystemDirectory - Gets the fully qualified path of the system directory.

    0 讨论(0)
  • 2020-12-11 16:50

    This should do it for you:

    Path.GetPathRoot(Environment.SystemDirectory)
    
    0 讨论(0)
提交回复
热议问题