Craig
Craig

Reputation: 1225

Create directory under local app data

I have application written in C/C++ and it needs to create a folder and file under the local app directory. When I call CreateDirectory the result is False and the directory is never created. What am I missing?

TCHAR szPath[MAX_PATH];
if (SUCCEEDED(SHGetFolderPath(NULL,CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, szPath)))
{
    PathAppend(szPath,_T("\\FredDir\\backupfirmware\\"));
    bool result = CreateDirectory(szPath, NULL);
}

As near as I can tell this should work.

Upvotes: 0

Views: 394

Answers (1)

Igor Tandetnik
Igor Tandetnik

Reputation: 52621

CreateDirectory can't create several levels worth of directories at once. You need to create them one by one - first FredDir, then backupfirmware under that.

Upvotes: 2

Related Questions