Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. adding data at the end of already exisiting file

adding data at the end of already exisiting file

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zahid_ash
    wrote on last edited by
    #1

    HI, A file "ABC.txt" has already been created using CFile and modes CFile::modeCreate | CFile::modeWrite | CFile::typeBinary Now I am opeing it using modes CFile::modeNoTruncate | CFile::modeWrite | CFile::typeBinary and write the data in it but it do not appeand the data at its end. I am also using CFile::SeekToEnd(); Whats the write ways to add data at the end of already existing file? thanks Regards.

    _ H 2 Replies Last reply
    0
    • Z zahid_ash

      HI, A file "ABC.txt" has already been created using CFile and modes CFile::modeCreate | CFile::modeWrite | CFile::typeBinary Now I am opeing it using modes CFile::modeNoTruncate | CFile::modeWrite | CFile::typeBinary and write the data in it but it do not appeand the data at its end. I am also using CFile::SeekToEnd(); Whats the write ways to add data at the end of already existing file? thanks Regards.

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      I had a file with some text in it. And this code successfully appends text to it.

      CStdioFile file;
      file.Open ("C:\\abc.txt",CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite );
      file.SeekToEnd ();
      file.WriteString ("Anshuman");
      file.Close ();
      

      Somethings seem HARD to do, until we know how to do them. ;-) _AnShUmAn_

      Z 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        I had a file with some text in it. And this code successfully appends text to it.

        CStdioFile file;
        file.Open ("C:\\abc.txt",CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite );
        file.SeekToEnd ();
        file.WriteString ("Anshuman");
        file.Close ();
        

        Somethings seem HARD to do, until we know how to do them. ;-) _AnShUmAn_

        Z Offline
        Z Offline
        zahid_ash
        wrote on last edited by
        #3

        Was there any problem with my way stated in above query? Regards.

        _ 1 Reply Last reply
        0
        • Z zahid_ash

          Was there any problem with my way stated in above query? Regards.

          _ Offline
          _ Offline
          _AnsHUMAN_
          wrote on last edited by
          #4

          You can achieve the same with your method.(using CFile) Post some code about how you are going with that and then we can comment on the change or modification you need to make. My Guess is that you may not be closing the file after creating it. Somethings seem HARD to do, until we know how to do them. ;-) _AnShUmAn_

          1 Reply Last reply
          0
          • Z zahid_ash

            HI, A file "ABC.txt" has already been created using CFile and modes CFile::modeCreate | CFile::modeWrite | CFile::typeBinary Now I am opeing it using modes CFile::modeNoTruncate | CFile::modeWrite | CFile::typeBinary and write the data in it but it do not appeand the data at its end. I am also using CFile::SeekToEnd(); Whats the write ways to add data at the end of already existing file? thanks Regards.

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            and this code is work or not work CFile file(_T("c:\\test.txt"),CFile::modeNoTruncate | CFile::modeWrite ); file.SeekToEnd(); file.Write(_T("test"),4); file.Close ();_**


            **_

            whitesky


            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups