how to trim path in C#

C#
path=Y:\Test\Project\bin\Debug
ans = String.Join(@"\", path.Split('\\').Skip(3));String dir = Path.GetDirectoryName(fullyQualifiedName);
string root = Directory.GetParent(dir).FullName;
Source

Also in C#: