Reading & Writing a file (uRGENT)
Hello everybody,
I have a structure of the following type,
data{
TInt A;
TInt B;
Tint C;
TBool D;
TBool E;
}
Now i want this structure to be written to a file and read back. Can anyone help me in solving this problem? lease provide some code so it will be clear.
Thanks in advance
I m able to write to file, but not getting the exact code to read
This is the code for writing, where iData contains the above declared structure,
RFileWriteStream Stream;
TInt Error = Stream.Replace(CEikonEnv::Static()->FsSession(),SaveSettingFile,EFileWrite);
if (KErrorNone == Error)
{
TRAP(Error,Stream.WriteL(TUint 8*)&(iData),sizeof(class ListData)));
Stream.close();
}
can u give me the code to read,...
thanks in advance
thanks for replying yucca
Re: Reading & Writing a file (uRGENT)
Hello,
How to write the following struct into a file ? can I use TPckgBuf ? and how.
struct TLicensePlugin
{
TInt iPluginId;
TInt iSubscriptionType;
TInt iDaysLeft;
};
struct TLicenseLocal
{
TInt iVersion;
TBuf<50> iLastTime;
TBuf<50> iUser;
TBuf<50> iPwd;
CArrayFixFlat<TLicensePlugin>* iPlugins;
};
If I don't include the last line, iPlugins, the structure is saved and loaded perfectly using the code posted before my post.
But I have this array of TLicensePlugin, that is another struct.
Do I need to write separately into a loop the elements of this array or can I insert somehow into the whole TPckgBuf buffer?
thanks.
Re: Reading & Writing a file (uRGENT)
Hi
TLicenseLocal in this instance is really not a T class/struct but rather a C class/struct. This is because is contains (owns) a C class which requires proper destruction.
I suggest you implement a new class called CLicenseLocal deriving from CBase. Add to this InternalizeL() and ExternalizeL() functions as well as a destructor that properly deletes all members.
In the InternalizeL and ExternalizeL you'll need to iteratively write each plugin data to the file. You'd probably also want to write the count so that you are able to easily InternalizeL.
Hope this helps.
Re: Reading & Writing a file (uRGENT)
Hi all,
How can we read an ascii file of encoding type ANSI ?????? or how can we convert TBuf8 to TBuf<256> ???????
Thanks,
Anoop
Re: Reading & Writing a file (uRGENT)
Hi all,
How can we convert file of encoding type ANSI to unicode file ??????
Thanks,
Aswathy
Re: Reading & Writing a file (uRGENT)
could you give me some help???
I need example code about writing arbitrary binary data in the file
thank you in advance