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);
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.
Forum posts: 364
Tint err=f1.Open(fsSession,KFileName,EFileRead);
Forum posts: 141
first u check the filesize then only read the data.
Forum posts: 187
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
Forum posts: 38
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.
Forum posts: 1321
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