How to save this object to file
Im my endeavour to create an object framework for a project, I have come to the conclusion that I need to add a "savefile" method to my CDocumentCollection class
This is a simple class.. it inherits collectionbase and contains an array with simple CDocument objects.
I want to do something like this
VB Code:
dim mycollection as new CDocumentCollection
mycollection.add(new CDocument("Doc1"))
mycollection.add(new CDocument("Doc3"))
mycollection.add(new CDocument("Doc14"))
mycollection.add(new CDocument("Doc156"))
mycollection.SaveToFile("c:\myfile.gps")
Is there an easy way to save the object hieararchy to binary file and an easy way to load it the same way? Im sure there are many programs in vb.net /C# that perform this simple thing... I just want to learn the "right" way to do it...
VB Code:
dim mycollection as new CDocumentCollection
mycollection = mycollection.LoadFromFile("c:\myfile.gps")
I have very little experience in these things, are there any patterns or rules to follow to make this a good design? I know a little about serialization... I have read it is a good way to save/load binary config files... can this help me? How do I proceed?
kind regards
Henrik