×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    339

    why unreadable file contents after using RFile Write() method?

    hi all, I am writing some text data using following code

    Code:
    _LIT(KSamepleText,"Hello World!\n");
    TPtrC8 data((TUint8*)(&KSamepleText)->Ptr(), (&KSamepleText)->Size());
    
    
    RFile file;
    TInt result = file.Open(CCoeEnv::Static()->FsSession(), fileName, EFileWrite);
    
    file.Write(data);
    file.Close();

    Opening the file in notepad shows "os) `À‘)¿‘)" . What is the problem with above code? I am testing this in emulator of S60 5th edition. Thanks

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,699

    Re: why unreadable file contents after using RFile Write() method?

    Because it writes some random data. _LIT declares a TLitC object, and that address-getting-casting magic probably mis-uses some part of this object, so you end up with saving some random memory location, although with the correct lenght.
    Unfortunately there is not a single word of explanation, but you can find an usable file-handling example on http://avalon.aut.bme.hu/~wizard (it shows saving and loading a series of files, all of them are "tagged" with .txt extension thus provide an easy way to check with Notepad).

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    339

    Re: why unreadable file contents after using RFile Write() method?

    Thanks wizard_hu_ for your link.

Similar Threads

  1. Replies: 1
    Last Post: 2010-06-28, 11:18
  2. Question marks using RFile.Write()
    By picciomitici in forum Symbian
    Replies: 3
    Last Post: 2009-05-05, 22:28
  3. How can I write binary values using RFile?
    By mabdulmoniem in forum Symbian
    Replies: 5
    Last Post: 2007-10-09, 14:12
  4. Replies: 4
    Last Post: 2007-09-11, 15:56
  5. Replies: 3
    Last Post: 2005-08-01, 13: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
  •  
×