Path.Combine absolute with relative path strings

后端 未结 7 1292
旧时难觅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条回答
  •  -上瘾入骨i
    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);
    

提交回复
热议问题