Good day,

such a situation, you need to put the file on a certain path, but there is a possibility that certain directories (folders) simply do not exist, then it is logical that you need to create them. Question: how to check the existence of all path directories, if they do not exist, then create them yourself?

Example: put on the way

D: \ some \ new \ directory \

Some folder is empty, i.e. need to create directory

D: \ some \ new \

and then

D: \ some \ new \ directory \

1 answer 1

Use Directory::CreateDirectory :

 Directory::CreateDirectory("D:\\some\\new\\directory\\"); 

Intermediate directories are created automatically if necessary.

  • And if this directory exists, then nothing will happen? - Koshachok
  • @koshachok: Nah, nothing will happen. Documentation writes: “Creates all directories unless they already exist .” - VladD