Creating nested directories

Tags: .NET

Just a quick tip to prevent others from feeling as foolish as I do:

The static CreateDirectory() method of the System.IO.Directory class will create the entire directory tree passed to it. There's no need to write an EnsurePathExists() method that recursively creates the folders. Absolutely no need. Not even just to be safe. It works. Trust me. Trust the framework. The framework is your friend.

[This has been a public service announcement by the Society for the Reinvention of the Wheel]

1 Comment

Comments have been disabled for this content.