×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    May 2007
    Posts
    91

    Write to file....

    Dear All,

    I want to write my structure into a file. But RWriteStream doesnt contain any function to write a struct or void pointer other that some text realted function. So can anybody plz tell me how to achive the task?

    Thanx & Regards,
    Vinod.

  2. #2
    Super Contributor
    Join Date
    Oct 2005
    Posts
    739

    Re: Write to file....

    Quote Originally Posted by VinodRaut
    Dear All,

    I want to write my structure into a file. But RWriteStream doesnt contain any function to write a struct or void pointer other that some text realted function. So can anybody plz tell me how to achive the task?

    Thanx & Regards,
    Vinod.
    As i understand, you are trying to write the vaues of variables in a structure to a file. AFAIK To do this task there is no easy ways other than write all the member name and its content respectively to the file as a step by step process. Correct me if i am wrong.

    Peter

  3. #3
    Regular Contributor
    Join Date
    May 2007
    Posts
    91

    Re: Write to file....

    Dear Peter...

    Yes i want to write a structure containing some different variables. Like we do in C --- write(iFileHandle, &strcut, sizeof(struct)); so can we do such in series60 or symbian?

    Thanx & Regards,
    Vinod.

  4. #4
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: Write to file....

    Quote Originally Posted by VinodRaut
    Dear Peter...

    Yes i want to write a structure containing some different variables. Like we do in C --- write(iFileHandle, &strcut, sizeof(struct)); so can we do such in series60 or symbian?

    Thanx & Regards,
    Vinod.
    you can do it like
    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL(fs);

    RFileWriteStream writer;
    writer.PushL();
    User::LeaveIfError(writer.Replace(fs,KC3SettingsFilename,EFileWrite));

    TBuf<20> aa;
    aa.Copy(_L("hi how r u"));
    writer << aImsi;

    writer.CommitL();
    writer.Pop();
    writer.Release();

    CleanupStack::PopAndDestroy();

    hope this will help you
    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

  5. #5
    Super Contributor
    Join Date
    Oct 2005
    Posts
    739

    Re: Write to file....

    Quote Originally Posted by VinodRaut
    Dear Peter...

    Yes i want to write a structure containing some different variables. Like we do in C --- write(iFileHandle, &strcut, sizeof(struct)); so can we do such in series60 or symbian?

    Thanx & Regards,
    Vinod.
    Ckeck the various Write methods available in RWriteStream. You can't a struct as a whole . you have done it in steps as writing each data one by one.

    Hope you understand me.

    Peter

  6. #6
    Regular Contributor
    Join Date
    May 2007
    Posts
    91

    Re: Write to file....

    Dear Jitendra...

    Thanx for the reply...
    so can i code like following?
    strcut strSample
    {
    TInt iVal1;
    TInt iVal2;
    TDesC<20> szVal3;
    };

    RFileWriteStream writer;
    strSample obj;
    // fill obj...
    writer << obj;
    ....

    Is this possible?

    Thanx & Regrads,
    Vinod

  7. #7
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: Write to file....

    i am not sure you can try it and please let me know, otherwise you can write every element individually.
    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

  8. #8
    Regular Contributor
    Join Date
    May 2007
    Posts
    91

    Re: Write to file....

    Dear Peter & Jitenrda..

    Thank you so much...

    I will try & let you know...

    Thanx & Regards,
    Vinod.

  9. #9
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Write to file....

    You can try wrapping it in a TPckgC.

    struct TMyStruct
    {
    TInt x;
    TIny y;
    TBuf<32> data;
    };

    TMyStruct myStructVariable;
    // set variable fields here....

    const TPckgC<TMyStruct> pkg(myStructVariable);
    aFile.Write(pkg);

  10. #10
    Regular Contributor
    Join Date
    May 2007
    Posts
    91

    Re: Write to file....

    Dear Paul...
    thamk you very much...

    Code given by u work wonder...
    while reading back the structure we have to use..

    RFileReadStream reader(rFile);
    TMyStruct myStructVariable;
    TPckg<TMyStruct> pkg(myStructVariable);
    reader.ReadL(pkg);

    Thanx & regards,
    Vinod.

Similar Threads

  1. [announce] PyUIQ. Python for UIQ 2.1 and 3.x
    By OscarBernabeu in forum Symbian
    Replies: 35
    Last Post: 2008-01-17, 09:12
  2. File write problem
    By want2beboss in forum Symbian
    Replies: 3
    Last Post: 2006-11-17, 11:22
  3. Write in a file with MIDP1.0
    By teivarf in forum Mobile Java General
    Replies: 1
    Last Post: 2003-11-19, 11:06
  4. read / write INI file
    By Jeepy in forum Symbian
    Replies: 1
    Last Post: 2003-02-10, 15:39

Posting Permissions

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