Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 DriveInfo 对象。我想知道驱动器是否是 Windows 驱动器(在我的 PC 上是 C:),因为您无法访问 Windows 驱动器的根目录。
您可以使用string path = Path.GetPathRoot(Environment.SystemDirectory);and 而不是再次检查驱动器名称,例如C:\or D:\, ...
string path = Path.GetPathRoot(Environment.SystemDirectory);
C:\
D:\