Question

I just working on some file management api in WinRT. I successfully created folder in ../Packages/myApp/LocalState/ but when I try to create new file (CreateFile2) in that folder I get this

error 4252: ERROR_NOT_SUPPORTED_IN_APPCONTAINER
This functionality is not supported in the context of an app container.

code:

localFolder = L"C:\\Users\\Tomas\\AppData\\Local\\Packages\\myApp\\LocalState\\my";
CreateDirectory(localFolder.c_str(),NULL);
localFolder += L"\\MyFile.txt";
CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams;
pCreateExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
pCreateExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
pCreateExParams.lpSecurityAttributes = NULL;
pCreateExParams.hTemplateFile = NULL;

HANDLE myfile = CreateFile2(localFolder.c_str(), GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, OPEN_ALWAYS, &pCreateExParams);
int error = GetLastError();

What I'm doing wrong? Should I set some options in manifest? Thank you for your help

Was it helpful?

Solution

Already found the problem - in pCreateExParams struct was some undefined values in .dwFileFlags and .dwSecurityQosFlags. So this works fine:

CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams = {0}; 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top