User::LeaveIfError(file.Replace(TheFs,KTestFile,EFileWrite)); // create the file for writing
RFile f=file; // create a new handle
RFileWriteStream out(f); // open the file as a stream
out.WriteL(KTestDes); // write some test data (to a buffer)
out.CommitL(); // commit the data (to file)
TInt iFileSize;
file.Size(iFileSize); // get the size of the file
out.Attach(file, iFileSize); // prepare to append data to the end of the new file
out.WriteL(KTestDes); // append the test data
out.Close(); // close the file with test data written twice
User::LeaveIfError(file.Open(TheFs,KTestFile,EFileRead)); // open the new file again for reading
f=file; // create a new handle
RFileReadStream in(f); // open the file as a stream
in.ReadL(buf); // read file data into a user buffer
in.Close(); // close the file (and use the data in buf)