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.
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.
Your code to create directories recursively will be as simple as:
Directory.CreateDirectory(path)
You can use Directory.CreateDirectory
in C# for creating directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With