他们有没有办法在不知道完整路径的情况下找到根目录。
例如,我有 Folder\subfolder
我想找到像 c:\, d:\, e:\
这样的根目录
子文件夹
在其中显示
我曾尝试使用 DirectoryInfo("path").Root.Name
、Path.GetPathRoot(path)
但它不起作用。
最佳答案
string path = ...
string root = Directory.GetDirectoryRoot(Path.GetFullPath(path));
关于c# - 在C#中查找没有完整路径的根目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18764236/