wp8-2.0-alpha problem in CCUserDefault


#1

version:Cocos2dx-2.1.0-wp8-2.0-alpha
some code:

CCUserDefault::sharedUserDefault()->setIntegerForKey(MAX_LEVEL,saveLevel);

I want to save the game level,but it didn’t work.
I debugged it,and found an error in “tinyxml.cpp”

bool TiXmlDocument::SaveFile(const wchar_t* filename) const
{
    FILE* fp = 0;
    errno_t err = _wfopen_s( &fp, filename, L"w" ); //in this line, the value of err is 24
       ...
}

then,I try to call flush method before and after saving game code. But it still didn’t work.

Does any mistakes in my code?
My english is very poor,and I’m sorry about that.I hope I describe this problem clearly.


#2

:frowning:
there is no code in method flush.
maybe,this is the reason.


#3

I still don’t know the reason, but I found a way to solve this problem.
that is calling the fcloseall ( or _fcloseall) function.


#4

Error 24 is too many files open.


#5

Virtual Void wrote:

Error 24 is too many files open.

yes.
But I don’t use the function like fopen or fopen_s in my code.
I’m afraid something wrong in cocos2d-x eng.


#6

fcloseall returns the number of files closed. Do you want to check how many?


#7

Virtual Void wrote:

fcloseall returns the number of files closed. Do you want to check how many?

yes,I have already done it.

I called it every game round,and it returned about 300.

_fclose may cause anothor problem. Some useful file stream was closed, and then game will force close.

:frowning: