I want to create a directory inside the %APPDATA% folder. I am using CreateDirectory() for this and it doesn't work. I debugged the code and it seems like the path is correct, but I can't see a new directory in my the APPDATA.
My code for creating dit in appdata:
void setAppDataDir(std::string name)
{
char* path;
size_t len;
_dupenv_s(&path, &len, "APPDATA");
AppDataPath = path;
AppDataPath += "\\"+name;
createDir(this->AppDataPath.c_str());
}
void createDir(const char* path)
{
assert(CreateDirectory((PCWSTR)path, NULL) || ERROR_ALREADY_EXISTS == GetLastError()); // no exception here
}
This is how I call the function:
setAppDataDir("thisistest");
I use Visual Studio 2019 and the debugger tells me, that path is
C:\\Users\\Micha\AppData\Roaming\\thisistest
What am I doing wrong?