static public String AbsoluteNormalizePath(String Path, String CurrentWorkingPath = "")
{
var Components = new LinkedList<String>();
// Normalize slashes.
Path = Path.Replace('\\', '/');
// Relative Path
if (Path.StartsWith("/"))
{
Path = CurrentWorkingPath + "/" + Path;
}
// Normalize Components
foreach (var Component in Path.Split('/'))
{
switch (Component)
{
case "": case ".": break;
case "..": Components.RemoveLast(); break;
default: Components.AddLast(Component); break;
}
}
return String.Join("/", Components).TrimStart('/');
}