I have an application that should create its settings directory inside the user directory% APPDATA%. To do this, use code similar to the following:
std::string appDataBase = getenv("APPDATA");
std::string appDir = appDataBase + "\\MyDir";
std::cerr << "About to invoke _mkdir(" << appDir << ")" << std::endl;
int rv = _mkdir(appDir.c_str());
std::cerr << "_mkdir returned " << rv << ", errno = " << errno << std::endl;
However, when this code works, the call _mkdirfails, and errno- EACCES:
About to invoke _mkdir(C:\Users\mdm\AppData\Roaming\MyDir)
_mkdir returned -1, errno = 13
I would suggest that this is a simple permission problem, except for the fact that (1) I can create the directory manually in Explorer without any permission problems, and (2) the same code works fine if I copy it into the project itself.
I conducted an extensive search for information about this problem, but I can find answers to common problems with permissions, such as a user who cannot access this folder using Explorer. The code in my application works if I run it as an Administrator, so itβs clear that something strange happens with its permissions, but I donβt know what else to check. I reviewed Process Explorer and confirmed that the application works with my user account, which has full write permissions in the% APPDATA% directory, and I made sure that the% APPDATA% tree is not set to Hidden or Read Only.
- " " " ", Windows, - ? , % APPDATA%, ?
, , . Development , _mkdir ; , .exe C:\Development ( Development ). Documents\Visual Studio\Projects, .
user729124