Basically, I want to be able to type a string and if the folders exist, good! Otherwise, make new ones. I'm doing this to save a file.
So for example, I want to save file "Test.txt" in folder "Test/Ex/LM/" where none of those directories exist. So the output would be to "Test/Ex/LM/Test.txt"
I tried using getline to get slashes from the string, and then CreateDirectory based before each slash, and it didn't work out for me, as CreateDirectory is only to the specific exe location. I also tried with with CreateDirectoryEx, but nothing was being created.
Here's a little pseudo-code I need to do but can't figure out how.
Code: Select all
void createFiles(string Dir) {
/*
Use getline to find everything by /'s.
Save all of these words into an array.
Go array by array to see if the folders exist.
If not, use CreateDirectoryEx to make a new file into the last array's folder.
^Having trouble figuring this function out. */
}
int main() {
createFiles("Test/Ex/LM/Test.txt");
}
I was doing:
CreateFileEx("","NewFile",NULL);
The first param is "" because I wanted to save it in the location of the program I'm running.
Any help is appreciated! Thanks!