Path.Combine absolute with relative path strings Path.Combine absolute with relative path strings windows windows

Path.Combine absolute with relative path strings


What Works:

string relativePath = "..\\bling.txt";string baseDirectory = "C:\\blah\\";string absolutePath = Path.GetFullPath(baseDirectory + relativePath);

(result: absolutePath="C:\bling.txt")

What doesn't work

string relativePath = "..\\bling.txt";Uri baseAbsoluteUri = new Uri("C:\\blah\\");string absolutePath = new Uri(baseAbsoluteUri, relativePath).AbsolutePath;

(result: absolutePath="C:/blah/bling.txt")


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)


Path.GetFullPath(@"c:\windows\temp\..\system32")?