Tim Van Wassenhove

Passionate geek, interested in Technology. Proud father of two

29 Oct 2009

Presenting PathBuilder

Currently it is annoying to build a path with Path.Combine

var home1 = Path.Combine(Path.Combine(Path.Combine("C", "Users"), "timvw"), "My Documents");

And here is how it can be:

var home2 = PathBuilder.Combine("C", "Users", "timvw", "My Documents");

The implementation is pretty simple:

public static class PathBuilder
	public static string Combine(params string[] parts)
		return parts.Aggregate((l, r) => Path.Combine(l, r));