We help IT Professionals succeed at work.

What is the equivalent of Delphi function ForceDirectories in C#

sepknow
sepknow asked
on
Medium Priority
1,643 Views
Last Modified: 2013-12-17
What is the equivalent of Delphi function ForceDirectories in C#?
This function will create folders/directories as many level as specified in the parameter passed to it.
For example, if I passed "C:\Temp\1\2\3" and there exist only C:\Temp, ForceDirectories will create '1', '2', '3' and I can write files to c:\temp\1\2\3 directory there after.
Comment
Watch Question

Hi,
This one should work:
Directory.CreateDirectory("E:\\1\\2\\3\\4");
With your example, the code should be: Directory.CreateDirectory("C:\\Temp\1\\2\\3");