C++ - Creating folder method
- by Matthew
I have the following method in C++:
void create_folder(LPCWSTR full_folder) //Method to create folder in case it does not exist
{
if(!CreateDirectory(full_folder,attr)) //Checking whether the folder already exists
{
switch (GetLastError())
{
case ERROR_ALREADY_EXISTS:
printf("The folder already exists!\n\n");
break;
case NULL:
printf("The folder does not exist!\n\n");
printf("The folder was created successfully!\n\n");
break;
}
}
}
In case the folder already exists, the correct message is displayed on the screen. However, if the folder does NOT exist, nothing is displayed on the screen, that is, the part identified by case NULL is not executed. How can I solve this problem?
In other words, how can I get the code after the case NULL to run if the folder does not exist?