Problem write data to file with RFileWriteStream ! Please help me ! Thanks!

Login to reply to this topic.
Thu, 2006-03-16 09:21
Joined: 2005-06-21
Forum posts: 107
Hi all !
I want to write data from file a.txt to b.txt by using "RFileWriteStream" and "RFileReadStream".But data doesn't write into b.txt file . Please help me to correct my code ! Thanks very much !.
//=============  This is my code ========
void CView01::WriteData()
{
      //=====   Connect to File server
      RFs aFs;
      User::LeaveIfError(aFs.Connect());
      CleanupClosePushL(aFs);
      _LIT( Filepath02, "C:\\b.txt");
      _LIT( Filepath01, "C:\\a.txt");

      //=====  Object for reading stream
      RFileReadStream fRead;
      //=====   Open a read stream
      User::LeaveIfError(fRead.Open(aFs, Filepath01, EFileRead));
      TInt8 pBuf1 = fRead.ReadInt8L();
      TInt8 pBuf2 = fRead.ReadInt8L();
      TInt8 pBuf3 = fRead.ReadInt8L();

      //=====   Write to File
      RFileWriteStream fWrite;
      //=====   Open a write stream
      User::LeaveIfError(fWrite.Create( aFs, Filepath02, EFileWrite ) );
      fWrite.WriteInt8L(pBuf1);
      fWrite.WriteInt8L(pBuf2);
      fWrite.WriteInt8L(pBuf3);

     CleanupStack::PopAndDestroy(&aFs);

}
//=========== doctinh113114===========

Thu, 2006-03-16 09:50
Joined: 2005-03-04
Forum posts: 176
Re: Problem write data to file with RFileWriteStream ! Please he
Maybe the file allready exists from a previous try?
Don't leave immeadiatly and look at the return code. If file couldn't  get created try it with open. Only if open failed too, leave.
Additional: try to open with "EFileWrite | EFileShareAny" and what about a commit and close of the streamwriter?

Hope this will help, bye;
CG
Thu, 2006-03-16 11:03
Joined: 2004-12-03
Forum posts: 276
Re: Problem write data to file with RFileWriteStream ! Please he

Today is a gift by GOD, that's why it is called the present.

Fri, 2006-03-17 07:53
Joined: 2005-06-21
Forum posts: 107
Re: Problem write data to file with RFileWriteStream ! Please he
Thanks very much !
  • Login to reply to this topic.