.Net - 从路径中删除点

ale*_*2k8 22 .net path

如何将"c:\ foo\..\bar"转换为"c:\ bar"?

Ran*_*pho 44

string path = Path.GetFullPath("C:\\foo\\..\\bar"); // path = "C:\\bar"
Run Code Online (Sandbox Code Playgroud)

更多信息


Col*_*ond 6

你有没有尝试过

string path = Path.GetFullPath(@"C:\foo\..\bar");
Run Code Online (Sandbox Code Playgroud)

在C#中使用System.IO.Path类?