Ray*_*Ray 55
尝试
Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.System));
Run Code Online (Sandbox Code Playgroud)
那将返回(通常)C:\
但这取决于你如何定义"主"硬盘.这将为您提供安装Windows的驱动器.
Wed*_*dge 18
这应该工作(假设你想要Windows打开的驱动器):
string rootDrive = Path.GetPathRoot(Environment.SystemDirectory);
Run Code Online (Sandbox Code Playgroud)