Path.Combine absolute with relative path strings

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

    For windows universal apps Path.GetFullPath() is not available, you can use the System.Uri class instead:

     Uri uri = new Uri(Path.Combine(@"C:\blah\",@"..\bling"));
     Console.WriteLine(uri.LocalPath);
    
    0 讨论(0)
提交回复
热议问题