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. Creating and saving to a file

Creating and saving to a file

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
7 Posts 3 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.
  • N Offline
    N Offline
    NewHSKid
    wrote on last edited by
    #1

    Hi, I have a program that sends messages over the internet. I now need to change it so that i can save the messages to a file. Can someone tell me how to read from a file, open a file, and save to a file? In my app, all my windows come up from drop down menus. So where should I open the file ?(once I know how) In the main class or the class where all the messages are made? thanks Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

    D 1 Reply Last reply
    0
    • N NewHSKid

      Hi, I have a program that sends messages over the internet. I now need to change it so that i can save the messages to a file. Can someone tell me how to read from a file, open a file, and save to a file? In my app, all my windows come up from drop down menus. So where should I open the file ?(once I know how) In the main class or the class where all the messages are made? thanks Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

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

      http://www.codeproject.com/script/comments/forums.asp?msg=593820&forumid=1647#xx593820xx You'll probably want to create a CStdioFile object if this is going to be a text file. Otherwise, if the messages belong to the document, take advantage of serialization. Most everything is already in place so it's fairly painless.

      N 1 Reply Last reply
      0
      • D David Crow

        http://www.codeproject.com/script/comments/forums.asp?msg=593820&forumid=1647#xx593820xx You'll probably want to create a CStdioFile object if this is going to be a text file. Otherwise, if the messages belong to the document, take advantage of serialization. Most everything is already in place so it's fairly painless.

        N Offline
        N Offline
        NewHSKid
        wrote on last edited by
        #3

        Hi, Can you explain a little more for me? What do you mean that the messages belong to the document? What is serialization? Did I do something wrong by asking the question yesterday and today? is that why you put the link to my question yesterday? If so, sorry. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

        RaviBeeR D N 3 Replies Last reply
        0
        • N NewHSKid

          Hi, Can you explain a little more for me? What do you mean that the messages belong to the document? What is serialization? Did I do something wrong by asking the question yesterday and today? is that why you put the link to my question yesterday? If so, sorry. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

          RaviBeeR Offline
          RaviBeeR Offline
          RaviBee
          wrote on last edited by
          #4

          NewHSKid wrote: What is serialization? See this[^] article. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

          1 Reply Last reply
          0
          • N NewHSKid

            Hi, Can you explain a little more for me? What do you mean that the messages belong to the document? What is serialization? Did I do something wrong by asking the question yesterday and today? is that why you put the link to my question yesterday? If so, sorry. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

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

            NewHSKid wrote: Did I do something wrong by asking the question yesterday and today? is that why you put the link to my question yesterday? If so, sorry. No, I was just making you aware that a previous attempt was made to point you in the right direction. NewHSKid wrote: Can you explain a little more for me? What do you mean that the messages belong to the document? What is serialization? I'm guessing that you have either an MDI or an SDI application. If that's the case, it's bound to have a CDocument-derived class. That class will have member variables, which might (it's up to you to decide the most appropriate spot) include the messages you are creating/sending/receiving. Serialization is well-documented in MSDN (this tool should become part of your arsenal). Here's an excerpt: “Serialization” is the process of writing or reading an object to or from a persistent storage medium, such as a disk file. MFC supplies built-in support for serialization in the class CObject. Thus, all classes derived from CObject can take advantage of CObject’s serialization protocol. The basic idea of serialization is that an object should be able to write its current state, usually indicated by the value of its member variables, to persistent storage.

            1 Reply Last reply
            0
            • N NewHSKid

              Hi, Can you explain a little more for me? What do you mean that the messages belong to the document? What is serialization? Did I do something wrong by asking the question yesterday and today? is that why you put the link to my question yesterday? If so, sorry. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

              N Offline
              N Offline
              NewHSKid
              wrote on last edited by
              #6

              Thanks for the help....I am reading your tutorial now Ravi. David, I am sorry, I didn't know where to go with the help i got yesterday. i thought maybe i would get someone to shed some light on how to understand it. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

              D 1 Reply Last reply
              0
              • N NewHSKid

                Thanks for the help....I am reading your tutorial now Ravi. David, I am sorry, I didn't know where to go with the help i got yesterday. i thought maybe i would get someone to shed some light on how to understand it. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

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

                The MSDN Scribble example goes a long way in showing the many facets of an MFC application. I suggest you study it in detail.

                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