Path.Combine absolute with relative path strings

后端 未结 7 1323
旧时难觅i
旧时难觅i 2020-11-27 05:08

I\'m trying to join a Windows path with a relative path using Path.Combine.

However, Path.Combine(@\"C:\\blah\",@\"..\\bling\") returns C:\\blah\\

7条回答
  •  广开言路
    2020-11-27 05:33

    This will give you exactly what you need (path does NOT have to exist for this to work)

    DirectoryInfo di = new DirectoryInfo(@"C:\blah\..\bling");
    string cleanPath = di.FullName;
    

提交回复
热议问题