CreateDirectory

using System.IO;

public static class MyExtensions
{
	/// <summary>
	/// Recursively create directory
	/// </summary>
	/// <param name="dirInfo">Folder path to create.</param>
	public static void CreateDirectory(this DirectoryInfo dirInfo)
	{
		if (dirInfo.Parent != null) CreateDirectory(dirInfo.Parent);
		if (!dirInfo.Exists) dirInfo.Create();
	}
}
Example:
string path = @"C:\temp\one\two\three";

var dir = new DirectoryInfo(path);
dir.CreateDirectory();

Description

Recursively create directory based on the given path. If the given path doesn't exist, it will create until all the folders in the path are satisfied.

Details

Double click on the code to select all.

 

;