Dear All,
I want to write my structure into a file. But RWriteStream doesnt contain any function to write a struct or void pointer other that some text realted function. So can anybody plz tell me how to achive the task?
Thanx & Regards,
Vinod.
Dear All,
I want to write my structure into a file. But RWriteStream doesnt contain any function to write a struct or void pointer other that some text realted function. So can anybody plz tell me how to achive the task?
Thanx & Regards,
Vinod.
As i understand, you are trying to write the vaues of variables in a structure to a file. AFAIK To do this task there is no easy ways other than write all the member name and its content respectively to the file as a step by step process. Correct me if i am wrong.Originally Posted by VinodRaut
Peter
Dear Peter...
Yes i want to write a structure containing some different variables. Like we do in C --- write(iFileHandle, &strcut, sizeof(struct)); so can we do such in series60 or symbian?
Thanx & Regards,
Vinod.
you can do it likeOriginally Posted by VinodRaut
RFs fs;
User::LeaveIfError(fs.Connect());
CleanupClosePushL(fs);
RFileWriteStream writer;
writer.PushL();
User::LeaveIfError(writer.Replace(fs,KC3SettingsFilename,EFileWrite));
TBuf<20> aa;
aa.Copy(_L("hi how r u"));
writer << aImsi;
writer.CommitL();
writer.Pop();
writer.Release();
CleanupStack::PopAndDestroy();
hope this will help you
Use Qt-Quick to make your application UI more attractive.
http://store.ovi.com/content/271896 | http://store.ovi.com/content/276199 | http://store.ovi.com/content/276202 | http://store.ovi.com/content/280827
Ckeck the various Write methods available in RWriteStream. You can't a struct as a whole . you have done it in steps as writing each data one by one.Originally Posted by VinodRaut
Hope you understand me.
Peter
Dear Jitendra...
Thanx for the reply...
so can i code like following?
strcut strSample
{
TInt iVal1;
TInt iVal2;
TDesC<20> szVal3;
};
RFileWriteStream writer;
strSample obj;
// fill obj...
writer << obj;
....
Is this possible?
Thanx & Regrads,
Vinod
i am not sure you can try it and please let me know, otherwise you can write every element individually.
Use Qt-Quick to make your application UI more attractive.
http://store.ovi.com/content/271896 | http://store.ovi.com/content/276199 | http://store.ovi.com/content/276202 | http://store.ovi.com/content/280827
Dear Peter & Jitenrda..
Thank you so much...
I will try & let you know...
Thanx & Regards,
Vinod.
You can try wrapping it in a TPckgC.
struct TMyStruct
{
TInt x;
TIny y;
TBuf<32> data;
};
TMyStruct myStructVariable;
// set variable fields here....
const TPckgC<TMyStruct> pkg(myStructVariable);
aFile.Write(pkg);
Dear Paul...
thamk you very much...
Code given by u work wonder...
while reading back the structure we have to use..
RFileReadStream reader(rFile);
TMyStruct myStructVariable;
TPckg<TMyStruct> pkg(myStructVariable);
reader.ReadL(pkg);
Thanx & regards,
Vinod.