n i have to write its content to a file, every time i need to append the content in my file... can
any one tell me hw can i do it ..
can any one give me small sample code...
But be aware as this code do not appen but write to the file at offset 0 each time it is called.
You can use RFile::Open, RFile::Seek to specify the offset you want to write to and then use RFileWriteStream::Attach to attach write stream to your file...
Forum posts: 56
http://www.newlc.com/topic-567
above might give you some clue. Please search in this forum. You will get lot of code snippets.
Forum posts: 61
Check for RFs and RFile APIs.
Forum posts: 5
Your code willl be something like this:
void SaveToFile (TDesC &aFileName, TDes8 &aBuf)
{
RFs fs;
RFile file;
fs.Connect ();
if (file.Create (fs, aFileName, EFileWrite | EFileShareAny) != KErrNone)
{
fs.Close ();
return;
}
file.Write (aBuf);
file.Close ();
fs.Close ();
}
Forum posts: 21
thank u..
if i want to append... i want to use RFileReadStream/RFileReadStream as i want to write TDes16 data to a file...
can u give me small sample code as above....
Thanks n Regards,
Sapna
Forum posts: 5
To write to file TDes16 using RFileWriteStream you can use following code
void WriteToFile (TDesC &aFileName, TDes &aBuf)
{
RFs fs;
RFileWriteStream file;
fs.Connect ();
CleanupClosePushL (fs);
if (file.Open (fs, aFileName, EFileWrite) != KErrNone)
{
CleanupStack::PopAndDestroy ();
return;
}
CleanupClosePushL (file);
file.WriteL (aBuf);
CleanupStack::PopAndDestroy (2);
}
But be aware as this code do not appen but write to the file at offset 0 each time it is called.
You can use RFile::Open, RFile::Seek to specify the offset you want to write to and then use RFileWriteStream::Attach to attach write stream to your file...