-
append to file
i have a list box. when i am pressing ok button on listbox the data is written in the file. but the problem is when another item is selected, the previous item is replace in the file.
is there any method to append data in file.
i am using RFs, RFile, RFileWriteStream
and to write data i use
RFileWriteStream writer;
writer<<buf;
-
Re: append to file
u can append to file this way:
use replace funtion to open a file also,
to write data into file,write(x,data); where x intially 0,then assign length of data+1 to x,
so next time when u write data into file it starts from data+1 and again.
-
Re: append to file
ya i know that but my problem is that i have data in
TBuf<256> nameBuf
and write accepts data in TDesC8
how can i change the namebuf from TBuf<> to TDesC8
-
Re: append to file
jusz copy TBuf<256> data into TBuf8<256> then "trimall"
-
Re: append to file
TBuf8<256> name;
name.Copy(nameBuf);
TDesC8& name1=name;
file.Write(0,name1);
is this the ok method. i am actually writing the contact ID (TInt ) of contact database.
when i was using writer<<nameBuf, the text file created showed the id properly ie. 13 or 14
but now is is showing unreadable character. is it ok
-
Re: append to file
TBuf8<256> name;
name.Copy(nameBuf);
y do u need this line ...i dont understand
/////////TDesC8& name1=name;
instead u can directly pass name into this
file.Write(0,name);
-
Re: append to file
thanks u verymuch
it was just now working fine but there is still one problem
after continuously adding two or three records it starts replacing the old ones.
is there any way to get the length of the file so that records are added each time at the end of the file.
thanks very much
-
Re: append to file
hi,
sunny
final soln for u:APPENDING
TInt x = 0;
TBuf8<10> data;
data.Copy(_L("hello"));
RFs fs;
fs.Connect();
RFile myfile;
myfile.Replace(fs,_L("c:\\myttt.txt"),EFileWrite);
for(TInt i =0 ;i<10;i++)
{
myfile.Write(x,data);
myfile.Size(x);
}
myfile.Close();
fs.Close();
-
Re: append to file
i solved the problem of consecutive clicks
i was making a mistake
i was doing TInt x - global declaration
x=name.Length()+1;
but i had to do
x=x+name.Length()+1;
everything is working fine but when i exit my application and again write data, it replaces the old data as the pointer position of x is lost
-
Re: append to file
thanks giridharn
i have a solution to this problem also.
i think i read the data of whole file and keep a counter increasing to know the length of all records .
and then pass it to write
is this solution feasible
thanks for your help
-
Re: append to file
thanks
i got the solution
i took the file size by using
TInt FileSize;
File.Size(FileSize);
mission accomplished
thanks very much
keep in touch
-
Re: append to file
Hi,
what is the use of logdata.Append(_L("")) logdata and append
-
Re: append to file
What kind of class is the [B]logdata[/B] variable instance of ? basically if you would know that, you could check the SDK docs for description on the function.