Read-only archive of the All About Symbian forum (2001–2013) · About this archive

can not display data from file......error occured...

0 replies · 1,264 views · Started 07 October 2003

I have the following codes in my program to write data to file and read from file......

_LIT(KTestFile,"C:\\System\\apps\\testdata\\testdata.dat"😉;
const TUint8* KTestData=_S8("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"😉;
const TInt KTestLength=36;
const TPtrC8 KTestDes(KTestData,KTestLength);

TBuf8<KTestLength+1> buf;
RFs TheFs;
RFile file;

User::LeaveIfError(TheFs.Connect());
User::LeaveIfError(file.Open(TheFs,KTestFile,EFileWrite));
RFile f=file;
RFileWriteStream out(f);
out.WriteL(KTestDes);
out.CommitL();

TInt iFileSize;
file.Size(iFileSize); // get the size of the file
out.Attach(file, iFileSize);
out.WriteL(KTestDes);
out.Close();

User::LeaveIfError(file.Open(TheFs,KTestFile,EFileRead));
RFile f=file;
RFileReadStream in(f);
in.ReadL(buf);
in.Close();
TheFs.Close();

HBufC* buf16 = HBufC::NewLC(buf.Length());
buf16->Des().Copy(buf);

Anyone know how to display the data inside the file on the screen(using the buf16)?

million thanks in advance.......