I recently blogged about a new method I noticed in .NET 4 on the Enum class. One of the great things about .NET 4 is that it is a new version of base class library too. In .NET 3.0 and 3.5 as we all know, the CLR and BCL was left at version 2.0 which meant there were practically no improvements to core system classes and such.

Well I just stumbled upon another welcome upgrade to a rusty old class. Path.Combine in .NET 4 takes a parameter array of parts.

// so code that used to look like this...
string documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string filename =
    Path.Combine(documents,
        Path.Combine("Visual Studio 2008",
            Path.Combine("Projects", "My Project");

// now looks like this...
string documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string filename = Path.Combine(documents, "Visual Studio 2008", "Projects", "MyProjects");