https://pt.stackoverflow.com/q/243891/101

CSharp · Console

/Program.cs

using static System.Console;
using System.IO;

public class Program {
    public static void Main() => WriteLine(Directory.GetParent("/Pasta1/Pasta2"));
}
;