problem while read a file through RFile
Login to reply to this topic.
Thu, 2006-04-06 14:56
Joined: 2006-02-15
Forum posts: 38
Hi,

I'm facing a problem while reading File through RFile. There is no compilation error. What I have doen for reading file is I have added a simple txt file in my project also added that in .mmp file. And trying to read data by using the following code.

RFs fsSession; // File server session
fsSession.Connect();
CleanupClosePushL(fsSession); // this will close the session in case
// we leave
RFile f1; // Represents a file, a subsession class
_LIT(KFileName,"c:\\system\\apps\\Fileman\\sortedcityList.txt");
TInt err=f1.Open(fsSession,KFileName,EFileRead);


User::LeaveIfError(err);
TBuf8 <10> Ch;
//TDes8 Ch;
err=f1.Read(Ch,6);
User::LeaveIfError(err);

the program is quit without comming to f1.Read(..) method

Advanced thanks

Thu, 2006-04-06 17:25
Joined: 2004-07-10
Forum posts: 364
and what is the value of err after

Tint err=f1.Open(fsSession,KFileName,EFileRead);
Fri, 2006-04-07 06:46
Joined: 2005-09-16
Forum posts: 141
Hi,

first u check the filesize then only read the data.

Fri, 2006-04-07 06:56
Joined: 2004-01-09
Forum posts: 187
No, No need to check the file size while using the function RFile::Read(TDes8&, TInt);
The TInt parameter itself will take care of the number of bytes to read from file. Ya but it should not be more then the maxlength of descriptor.

bashirpk, you must see the leave value you are getting at

TInt err=f1.Open(fsSession,KFileName,EFileRead);

because if err is not KErrNone, then

User::LeaveIfError(err);

Will leave and close the application gracefully. So problem is somewhere in opening the file.

BR
Chetan

----
Chetan Kulshrestha

Fri, 2006-04-07 07:13
Joined: 2006-02-15
Forum posts: 38
Thank you very much for replies from all who replied.

mungbeans the value of err after
TInt err=f1.Open(fsSession,KFileName,EFileRead);
is -12


and after execution of this line the application is closed.
Fri, 2006-04-07 07:40
Joined: 2005-11-20
Forum posts: 1321
Now, with the help of the Symbian error code list, one sees that -12 = KErrPathNotFound (see the "sticky" thread about error codes in this forum).

So there must be something wrong with C:\System\Apps\Fileman...

If you are working on the emulator, you probably should use the Z: drive letter instead of C:

René Brunner


copyright 2003-2009 NewLC SARL