×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    84

    After writing file in binary format the file is reable

    I am trying to write into a file in binary format.

    RFile file;
    err = file.Open(fsSession, KFileName, EFileWrite | EFileStream ); //EFileStream is binary mode..
    _LIT(KText,"Hello");

    RFileWriteStream outputFileStream( file );
    CleanupClosePushL( outputFileStream );
    outputFileStream << KText;


    The file is created bur when i open the file with notepad the contents are reable... Any body any idea

    Thanks

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: After writing file in binary format the file is reable

    Hi,

    you mean that the data are not readable? Thats because when you are writing to the stream using '<<' and '>>' operators on descriptors, there are some additional binary data written, like descriptor lenght, type, etc. So you cannot use it as a normal text file. You should use operator with 'char' type or use RFile and save plain text into fie.

    BR
    STeN

  3. #3
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    84

    Re: After writing file in binary format the file is reable

    No.. I meant if am writing in binary mode ,i should not able to read it as text right ? But when i created , ican see plain "Hello" string.. in the file.. ?

    Can i not use RFileWriteStream to write binary data?

    can you tell me how to write my text in binary format to a file...

    Thanks

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: After writing file in binary format the file is reable

    Hi,

    using the code you paste here you don't create plain text file. There is something like "<header>Hello" in the file. Might be that by some editor the header is ignored, because it is not displayable string, so it looks like text file. In the header is character width ( 8 or 16 lenght) and length (in characters).

    If you want to make your text unreadable you have to use some encryption (i.e DES, AES...)

    BR
    STeN

  5. #5
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    84

    Re: After writing file in binary format the file is reable

    Thanks very much... I dont want to use any encryption. Just need my file to be in binary mode....

    Thanks

  6. #6
    Regular Contributor
    Join Date
    Oct 2007
    Location
    Coimbatore,India
    Posts
    114

    Re: After writing file in binary format the file is reable

    Quote Originally Posted by Rajani_sp View Post
    No.. I meant if am writing in binary mode ,i should not able to read it as text right ? But when i created , ican see plain "Hello" string.. in the file.. ?

    Can i not use RFileWriteStream to write binary data?

    can you tell me how to write my text in binary format to a file...

    Thanks
    You are right, every file you open(for writing or reading) may be a text file or a binary file. Mostly it'll be a binary file.
    For further details read the f32file.h file.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,569

    Re: After writing file in binary format the file is reable

    All files are binary files. And when you write text to them, it is going to be readable. Check the explanation in TFileMode or any C/C++ book to find out what "text file" mode does.

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. How to read binary large binary file from...
    By gaudeamus1313 in forum Mobile Java General
    Replies: 5
    Last Post: 2007-03-20, 19:17
  3. reading from a file and writing to another file
    By ibraheemJazba in forum Symbian
    Replies: 3
    Last Post: 2007-03-08, 11:50
  4. S60 theme questions
    By Nokian_Spb in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2006-08-17, 06:11
  5. saving of file in binary format
    By juliaf in forum Symbian
    Replies: 1
    Last Post: 2005-08-15, 07:42

Posting Permissions

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