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. File writeing [modified]

File writeing [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
8 Posts 5 Posters 0 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.
  • V Offline
    V Offline
    VinayCool
    wrote on last edited by
    #1

    Hi All, I want to write the contents of the edit box to file i have used this code but its not working can u tell me the cause.. i want to remove the old contetns and add the contetns of the edit box. str holds the file name. CStdioFile file(str, CFile::modeWrite); file.Open(str); char *pBuffer = new char[dwSize + 1]; m_FCONT.GetWindowText(*pBuffer); UINT uWrite = file.Write(pBuffer, dwSize); delete [] pBuffer; Regards, Vinay Charan.

    H T D A 4 Replies Last reply
    0
    • V VinayCool

      Hi All, I want to write the contents of the edit box to file i have used this code but its not working can u tell me the cause.. i want to remove the old contetns and add the contetns of the edit box. str holds the file name. CStdioFile file(str, CFile::modeWrite); file.Open(str); char *pBuffer = new char[dwSize + 1]; m_FCONT.GetWindowText(*pBuffer); UINT uWrite = file.Write(pBuffer, dwSize); delete [] pBuffer; Regards, Vinay Charan.

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

      you can use (CArchive /CFile)for your work_**


      **_

      whitesky


      V 1 Reply Last reply
      0
      • H Hamid Taebi

        you can use (CArchive /CFile)for your work_**


        **_

        whitesky


        V Offline
        V Offline
        VinayCool
        wrote on last edited by
        #3

        Hi whitesky, I have used CFile but i am nt getting how to save in the file can u plz c the code. Regards, Vinay Charan.

        H 2 Replies Last reply
        0
        • V VinayCool

          Hi whitesky, I have used CFile but i am nt getting how to save in the file can u plz c the code. Regards, Vinay Charan.

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

          See one example Here[^] maybe it is some helpful to you_**


          **_

          whitesky


          1 Reply Last reply
          0
          • V VinayCool

            Hi whitesky, I have used CFile but i am nt getting how to save in the file can u plz c the code. Regards, Vinay Charan.

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

            and one simple example CFile m_File("c:\\text2.txt",CFile::modeCreate|CFile::modeWrite); TCHAR buf[120]; m_Edit1.GetWindowText(buf,sizeof(buf)); m_File.Write(buf, lstrlen(buf)); m_File.Close();_**


            **_

            whitesky


            1 Reply Last reply
            0
            • V VinayCool

              Hi All, I want to write the contents of the edit box to file i have used this code but its not working can u tell me the cause.. i want to remove the old contetns and add the contetns of the edit box. str holds the file name. CStdioFile file(str, CFile::modeWrite); file.Open(str); char *pBuffer = new char[dwSize + 1]; m_FCONT.GetWindowText(*pBuffer); UINT uWrite = file.Write(pBuffer, dwSize); delete [] pBuffer; Regards, Vinay Charan.

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              In Continuation with WhiteSky,   better option will CStdioFile, which deal will Text based File

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

              1 Reply Last reply
              0
              • V VinayCool

                Hi All, I want to write the contents of the edit box to file i have used this code but its not working can u tell me the cause.. i want to remove the old contetns and add the contetns of the edit box. str holds the file name. CStdioFile file(str, CFile::modeWrite); file.Open(str); char *pBuffer = new char[dwSize + 1]; m_FCONT.GetWindowText(*pBuffer); UINT uWrite = file.Write(pBuffer, dwSize); delete [] pBuffer; Regards, Vinay Charan.

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                VinayCool wrote:

                ...but its not working

                What is not working? Be specific.

                VinayCool wrote:

                file.Open(str);

                It is not necessary to call the Open() method. The constructor has already done this.


                "The largest fire starts but with the smallest spark." - David Crow

                1 Reply Last reply
                0
                • V VinayCool

                  Hi All, I want to write the contents of the edit box to file i have used this code but its not working can u tell me the cause.. i want to remove the old contetns and add the contetns of the edit box. str holds the file name. CStdioFile file(str, CFile::modeWrite); file.Open(str); char *pBuffer = new char[dwSize + 1]; m_FCONT.GetWindowText(*pBuffer); UINT uWrite = file.Write(pBuffer, dwSize); delete [] pBuffer; Regards, Vinay Charan.

                  A Offline
                  A Offline
                  anwer_skk
                  wrote on last edited by
                  #8

                  try this; char buff[] = "Test Data"; CStdioFile file("c:\\Test.txt", CFile::modeCreate | CFile::modeWrite); file.WriteString( buff ); file.Close(); i think you forget to set file creation open flag.

                  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