How to create multiple directories from a single full path in C#?

I would call Directory.CreateDirectory(@"C:\dir0\dir1\dir2\dir3\dir4\").

Contrary to popular belief, Directory.CreateDirectory will automatically create whichever parent directories do not exist.
In MSDN’s words, Creates all directories and subdirectories as specified by path.

If the entire path already exists, it will do nothing. (It won’t throw an exception)

Leave a Comment