CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2001
    Location
    germany
    Posts
    772

    add bytes to binary file

    Hi!

    how can I add a byte to the end of a binary file? Let's say i want to add a 0xFF to it?
    Also, any method to append a whole .bin file to another one?
    (except : system(copy /b ....) )
    Thanks in advance!

    radu
    Please rate if it helps!

    * The second mouse gets the cheese.

    * Birthdays are good for you. The more you have, the longer you live.

    * Always keep your words soft and sweet, just in case you have to eat them.

    * Always read stuff that will make you look good if you die in the middle of it.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: add bytes to binary file

    1. MFC CFile Class:
    Open with CFile::modeWrite | CFile::modeNoTruncate, call CFile::SeekToEnd, and CFile::Write.
    2. Using Win 32 API:
    CreateFile, SetFilePointer, WriteFile

  3. #3
    Join Date
    Feb 2005
    Location
    Pune (India)
    Posts
    644

    Thumbs up Re: add bytes to binary file

    hi,

    which platform and compiler you are using... ?

    follow the steps

    1) Open File using ............Open
    2) seek to end of file (set file pointer to end of file),...... Seek()
    3) write byte using.............. WriteFile()


    Othere API and classes useful

    Classs
    CFile

    API
    CreateFile (),ReadFile,WriteFile , Seek...............

    in C
    fopen(),fread,fwrite.........



    -Anant
    "Devise the simplest possible solution that solves the problems"

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured