Click here to Skip to main content
15,891,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,


Is ther any function in C++ on windows(win32 or MFC) for

1 ) Creating a directory tree at given path.
e.g. if path is c\Test1\Test2\Test3
Then the function should create all directories which does not exist on the disk.
I know we can achieve this by tokenizing the path and using CreateDirectory function on each directoey, but i am looking for a readymade function to do this task.
Posted

1 solution

Yes, there is such a function: SHCreateDirectoryEx
[^]. To use it you must include shlobj.h and link with shell32.lib.
 
Share this answer
 
v2
Comments
chandanadhikari 2-Oct-13 9:41am    
hi Jochen Arndt,
the link leads to a page saying 'content not found'. Can you please check this.
Jochen Arndt 2-Oct-13 10:14am    
Fixed. The last letter of the link was lost during copy and paste.
Member 13769320 28-Jun-18 1:31am    
How do I dynamically create a folder or directory in C++?
Why my code does not work?
cout << "\n\tEnterProject Name: ";
cin >> projectName;
cout << "\n\tProject Name: " << projectName << endl;
//CreateDirectoryA("C:\\" + projectName, NULL);
PrafullaVedante 29-Jun-18 5:08am    
You have commented the CreateDirectoryA call.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900