first i asume that u use this piece of code in a GUI based application , because in an exe u won't be able to get a RFs like u did. Second check the return codes of every method that u used... if all is ok u should get KErrNone.
TBuf8<128> FileContents; FileContents.Append(iInterval); // iInterval is an TInt FileContents.Append('\n'); FileContents.Append(iGetLocation); // iGetLocation is a boolean FileContents.Append('\n'); FileContents.Append(iCreateLog); //createLog is a boolean FileContents.Append('\n'); FileContents.Append(iTimerActive); // itimer activer is also boolean FileContents.Append('\n'); iErr =file.Write(FileContents);// i am getting runtime here
for this, first u check file exists or not using Baflutils::FileExists(). if file exists, then open the file and write data. else create the file for write and write the data
iErr != KErrNotFound, this doesn't means that your file reference has created there might be other problems like already in use.
So better use it like this.
RFs aFs; Â aFs.Connect(); RFile file; Â TInt iErr = file.Open(aFs,KLTrackSettingsFile,EFileWrite); Â if (iErr == KErrNone) Â Â {
TBuf8<128> FileContents; Â FileContents.Append(iInterval); // iInterval is an TInt FileContents.Append('\n'); FileContents.Append(iGetLocation); // iGetLocation is a boolean FileContents.Append('\n'); FileContents.Append(iCreateLog); //createLog is a boolean FileContents.Append('\n'); FileContents.Append(iTimerActive); // itimer activer is also boolean FileContents.Append('\n'); iErr =file.Write(FileContents); } else { // Handle error }
What is file, an RFile presumbably but did you open it etc., what is the run time error, etc.?
Forum posts: 15
library: efsrv.lib
file.Replace( CEikonEnv::Static()->FsSession(), _L("c:\\test.txt"), EFileWrite );
file.Write( _L8("test") );
file.Close();
hope this helps
best regards,
Ronald Stevanus
Forum posts: 31
First Let us know what you want towrite ?
Point 1. You want to write Textl Data into the file
Point 2. You want to write the binary data into the file?
Binary data (When you want copy some image audio or video data)
Because both has the diffrent mechanism to write in
the file.
Make your question clear
Regards
Ranjeet
Forum posts: 206
first i asume that u use this piece of code in a GUI based application , because in an exe u won't be able to get a RFs like u did. Second check the return codes of every method that u used... if all is ok u should get KErrNone.
guda
Forum posts: 80
and thanks for taking interest
my code is as follows
RFs aFs;
aFs.Connect();
RFile file;
TInt iErr = file.Open(aFs,KLTrackSettingsFile,EFileWrite);
if (iErr != KErrNotFound)
{
TBuf8<128> FileContents;
FileContents.Append(iInterval);
// iInterval is an TInt
FileContents.Append('\n');
FileContents.Append(iGetLocation);
// iGetLocation is a boolean
FileContents.Append('\n');
FileContents.Append(iCreateLog);
//createLog is a boolean
FileContents.Append('\n');
FileContents.Append(iTimerActive);
// itimer activer is also boolean
FileContents.Append('\n');
iErr =file.Write(FileContents);// i am getting runtime here
error is as follows
38c6f
KERN-EXEC 0
Vasant Patel.
Sr. Software Engineer.
S60 2nd Ed., S60 3rd Ed., Win32.
Forum posts: 141
for this, first u check file exists or not using Baflutils::FileExists().
if file exists, then open the file and write data.
else create the file for write and write the data
it'll help for u
Forum posts: 188
iErr != KErrNotFound, this doesn't means that your file reference has created there might be other problems like already in use.
So better use it like this.
RFs aFs; Â
aFs.Connect();
RFile file;
Â
TInt iErr = file.Open(aFs,KLTrackSettingsFile,EFileWrite);
Â
if (iErr == KErrNone)
  {
TBuf8<128> FileContents; Â
FileContents.Append(iInterval);
// iInterval is an TInt
FileContents.Append('\n');
FileContents.Append(iGetLocation);
// iGetLocation is a boolean
FileContents.Append('\n');
FileContents.Append(iCreateLog);
//createLog is a boolean
FileContents.Append('\n');
FileContents.Append(iTimerActive);
// itimer activer is also boolean
FileContents.Append('\n');
iErr =file.Write(FileContents);
}
else
{
// Handle error
}
file.Close();
aFs.Close();
*********
BR
Chetan
----
Chetan Kulshrestha
Forum posts: 80
thanks very much for your kind interest
my problem is solved
and the problem was that unknowingly
my file was already opened and i was trying to reopen.
thanks.
Vasant Patel.
Sr. Software Engineer.
S60 2nd Ed., S60 3rd Ed., Win32.