Creating and saving to a file
-
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)
-
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)
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. -
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.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)
-
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)
-
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)
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. -
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)
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)
-
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)
The MSDN Scribble example goes a long way in showing the many facets of an MFC application. I suggest you study it in detail.