reading from ini file

Login to reply to this topic.
Thu, 2004-11-11 11:42
Joined: 2004-11-01
Forum posts: 4
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.

Thu, 2004-11-11 11:58
Joined: 2004-05-24
Forum posts: 981
Re: reading from ini file
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

Hope it helps

Lucian

pirosl

Tue, 2005-05-10 13:53
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: reading from ini file
Quote from: pirosl
CDictionaryStore* iniFile = iApplication->OpenIniFileLC(CCoeEnv::Static()->FsSession());

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.

Tue, 2005-05-10 14:22
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
reading from ini file
Code:
CDictionaryStore* iniFile = Application()->OpenIniFileLC(iEikonEnv->FsSession ());

After using the above code it's working fine!!!    Cheezy

Tue, 2005-05-10 14:36
Joined: 2004-05-24
Forum posts: 981
reading from ini file
Quote from: vinsofts
Code:
CDictionaryStore* iniFile = Application()->OpenIniFileLC(iEikonEnv->FsSession ());

After using the above code it's working fine!!!    Cheezy

From where are you trying to write in ini file?

pirosl

Tue, 2005-05-10 16:54
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
reading from ini file
I want to write the application settings into the application's ini file. I had  written the above mensioned code in my AppUi class.

Wed, 2005-05-11 07:45
Joined: 2004-05-24
Forum posts: 981
reading from ini file
Quote from: vinsofts
I want to write the application settings into the application's ini file. I had  written the above mensioned code in my AppUi class.

Yes then it's ok

pirosl

Wed, 2005-07-27 00:26
Joined: 2005-05-27
Forum posts: 18
Re: reading from ini file
Hello,

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
Wed, 2005-07-27 11:28
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: reading from ini file
Quote from: jcintra
CDictionaryStore* iniFile = iApplication->OpenIniFileLC(CCoeEnv::Static()->FsSession());

In which class you wrote the above line?

Wed, 2005-07-27 17:03
Joined: 2005-05-27
Forum posts: 18
Re: reading from ini file
Thanks, I wasn't understanding the meaning of 'Appliction()'...
Wed, 2005-07-27 17:47
Joined: 2004-05-24
Forum posts: 981
Re: reading from ini file
Quote from: jcintra
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?

pirosl

  • Login to reply to this topic.