Reputation: 2042
I need a script that can create a sub folders automaticaly.
For example:
I have a base folder stored at c:/upload
. I tranfer to script folders string: /2011/23/12/3
. Script should parse this string and create folders and subfolders in c:/upload
like string is (should be c:/upload/2011/23/12/3
)
How can I make this?
Now I use if/else and check if folder/subfolder exist, but the script is tooooo big and that is hard to manage.
Upvotes: 7
Views: 15656
Reputation: 15566
Your code to create directories recursively will be as simple as:
Directory.CreateDirectory(path)
Upvotes: 6
Reputation: 1500555
Have you looked at Directory.CreateDirectory
, which will create any missing directories along the way?
From the documentation:
Any and all directories specified in path are created, unless they already exist or unless some part of path is invalid.
Upvotes: 18