EnsureDirectoryExists helper function

Below is a simple EnsureDirectoryExists helper function:

public static void EnsureDirectoryExists(string targetPath)
        {
            string dir = Path.GetDirectoryName(targetPath);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
        }