Problem write data to file with RFileWriteStream ! Please help me ! Thanks!
| Thu, 2006-03-16 09:22 | |
|
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=========== |
|






Forum posts: 59
Forum posts: 2009
Call fWrite.CommitL() to ensure data are written on disk (or fWrite.Close() if you don't need it anymore).
Note also that you should push fRead and fWrite on the cleanup stack and destroy them before before destroying your RFs session.
Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant