hello, I trying to read from and write to an (ini) file in symbian 6.1 using SDK 1.2, till now I couldn't find the right way to do that, can any one help me? where can I find examples to explain more about that.
For reading you can try this void CMyIni::ReadIniFile() CDictionaryStore* iniFile = iApplication->OpenIniFileLC(CCoeEnv::Static()->FsSession()); if (iniFile->IsPresentL(aUid)) { RDictionaryReadStream stream; stream.OpenLC(*iniFile,aUid); iModeType = stream.ReadInt32L(); //reading an int value stream >> iTextBuf; //reading a string CleanupStack::PopAndDestroy(); // stream } else { iModeType = 0; // give it a default value if there are no settings in the system ini iTextBuf.Copy(_L("")); } CleanupStack::PopAndDestroy(); //iniFile }
And for write you can do like this void CMyIni::WriteIniFile() { CDictionaryStore* iniFile = iApplication->OpenIniFileLC(CCoeEnv::Static()->FsSession()); RDictionaryWriteStream stream; stream.AssignLC( *iniFile, aUid ); stream.WriteInt32L(iModeType); //write an int stream << iTextBuf; //write a string stream.CommitL(); CleanupStack::PopAndDestroy(); iniFile->CommitL(); CleanupStack::PopAndDestroy(); }
In the code you can see a aUid. This can be smth like const TUid aUid = {0x0001}; and you'll put it in you cpp file
How can we create an object (iApplication) of App class in our AppUi class... For me it's throwing an error in run time... While debugging I found that its in that line the error is showing.
Thanks, I wasn't understanding the meaning of 'Appliction()'...
The question still remains. In what class are you calling the code? Or better say...what class is extending the class from which are you making the call?
Forum posts: 981
void CMyIni::ReadIniFile()
CDictionaryStore* iniFile = iApplication->OpenIniFileLC(CCoeEnv::Static()->FsSession());
if (iniFile->IsPresentL(aUid))
{
RDictionaryReadStream stream;
stream.OpenLC(*iniFile,aUid);
iModeType = stream.ReadInt32L(); //reading an int value
stream >> iTextBuf; //reading a string
CleanupStack::PopAndDestroy(); // stream
}
else
{
iModeType = 0; // give it a default value if there are no settings in the system ini
iTextBuf.Copy(_L(""));
}
CleanupStack::PopAndDestroy(); //iniFile
}
And for write you can do like this
void CMyIni::WriteIniFile()
{
CDictionaryStore* iniFile = iApplication->OpenIniFileLC(CCoeEnv::Static()->FsSession());
RDictionaryWriteStream stream;
stream.AssignLC( *iniFile, aUid );
stream.WriteInt32L(iModeType); //write an int
stream << iTextBuf; //write a string
stream.CommitL();
CleanupStack::PopAndDestroy();
iniFile->CommitL();
CleanupStack::PopAndDestroy();
}
In the code you can see a aUid. This can be smth like
const TUid aUid = {0x0001};
and you'll put it in you cpp file
Hope it helps
Lucian
pirosl
Forum posts: 732
How can we create an object (iApplication) of App class in our AppUi class... For me it's throwing an error in run time... While debugging I found that its in that line the error is showing.
Forum posts: 732
After using the above code it's working fine!!!
Forum posts: 981
After using the above code it's working fine!!!
From where are you trying to write in ini file?
pirosl
Forum posts: 732
Forum posts: 981
Yes then it's ok
pirosl
Forum posts: 18
when I use
CDictionaryStore* iniFile = iApplication->OpenIniFileLC(CCoeEnv::Static()->FsSession());
I'm always getting:
error C2227: left of '->OpenIniFileLC' must point to class/struct/union
How can I solve this problem ?
Thanks
Forum posts: 732
In which class you wrote the above line?
Forum posts: 18
Forum posts: 981
The question still remains. In what class are you calling the code? Or better say...what class is extending the class from which are you making the call?
pirosl