Path.Combine absolute with relative path strings

后端 未结 7 1291
旧时难觅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:14

    Call Path.GetFullPath on the combined path http://msdn.microsoft.com/en-us/library/system.io.path.getfullpath.aspx

    > Path.GetFullPath(Path.Combine(@"C:\blah\",@"..\bling"))
    C:\bling
    

    (I agree Path.Combine ought to do this by itself)

提交回复
热议问题