×

Discussion Board

Results 1 to 13 of 13

Thread: append to file

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    135

    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;

  2. #2
    Regular Contributor
    Join Date
    Oct 2004
    Location
    india
    Posts
    306

    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.

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    135

    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

  4. #4
    Regular Contributor
    Join Date
    Oct 2004
    Location
    india
    Posts
    306

    Re: append to file

    jusz copy TBuf<256> data into TBuf8<256> then "trimall"

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    135

    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

  6. #6
    Regular Contributor
    Join Date
    Oct 2004
    Location
    india
    Posts
    306

    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);

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    135

    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

  8. #8
    Regular Contributor
    Join Date
    Oct 2004
    Location
    india
    Posts
    306

    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();

  9. #9
    Registered User
    Join Date
    Aug 2005
    Posts
    135

    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

  10. #10
    Registered User
    Join Date
    Aug 2005
    Posts
    135

    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

  11. #11
    Registered User
    Join Date
    Aug 2005
    Posts
    135

    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

  12. #12
    Registered User
    Join Date
    Dec 2012
    Posts
    1

    Re: append to file

    Hi,
    what is the use of logdata.Append(_L("")) logdata and append

  13. #13
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,144

    Re: append to file

    What kind of class is the logdata variable instance of ? basically if you would know that, you could check the SDK docs for description on the function.

Similar Threads

  1. Tips on using NDS 1.1
    By mitts in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2006-01-18, 16:07
  2. Replies: 1
    Last Post: 2005-05-26, 14:22
  3. Series 60 SDK Appwizard on windows xp
    By moonjoor in forum Symbian Tools & SDKs
    Replies: 15
    Last Post: 2003-12-24, 10:22
  4. nokia 7210 modem via IR doesn't work !
    By oussamaaiadi in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2003-03-06, 10:46
  5. Replies: 0
    Last Post: 2002-06-10, 12:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •