I am working on a side project for a small business owner (my father) and part of the requirements for the application include saving customer and job related data in a way that it can easily be backed up and/or restored on demand.

I am familiar with how to save data to a flat file, and I am familiar with how to save data to a database. What I feel like I am missing is what are "typical" strategies for saving data such as I described above to a file?

For example I noticed Quickbooks has their own file format that encapsulates an entire "business" in one file that can easily be backed up and/or used for restoration. (Briefly) How is that accomplished?

I have come across integrated databases such as sqlExpress and am left wondering if this is how end user applications typically manage data or if it is something else entirely.

In short, how can I encapsulate a large amount of complex data into a single file either of a simple data type (i.e. .DAT/.TXT) or possibly a custom file format?

EDIT: As an added bit of information I would like to avoid having to install a stand-alone RDBMS in order to save data to a database.

  • if the amount of data is not astronomical check simple Dataset i has a save to xml feature. The file is humanly readable and as easy to copy and bright it with you.
    – Franck
    Commented Feb 12, 2015 at 21:29
  • hmm do you have a link available? Or as you saying use the DataSet class and save to an XML file? Commented Feb 12, 2015 at 21:32
  • simply use dataset object as data holder and save/load with dataSet.WriteXml("data.xml", XmlWriteMode.WriteSchema); and dataSet.ReadXml("data.xml", XmlReadMode.ReadSchema);
    – Franck
    Commented Feb 13, 2015 at 12:47
  • I like that a lot actually, if you want to post that as a complete answer I think that is what I am going to do Commented Feb 13, 2015 at 14:16
  • 1
    Adam already detailed a bit my solution. you should accept his. He also linked the MSDN page
    – Franck
    Commented Feb 13, 2015 at 14:18

3 Answers 3


Building on Franck's comment, you can use a DataSet to save to XML.

Writing DataSet Contents as XML Data

System.IO.StreamWriter xmlSW = new System.IO.StreamWriter("Customers.xml");

// This example assumes you have a custom dataset called ds holding customer data
ds.WriteXml(xmlSW, XmlWriteMode.WriteSchema);


This will produce an XML file called Customers.xml in your current directory that is a serialized version of your DataSet.

You will also need to know how to load that data back into your objects... Loading a DataSet from XML

// Load the dataset from a file called input.xml
DataSet ds = new DataSet();
ds.ReadXml("Customers.xml", XmlReadMode.ReadSchema);

Depending on what kind of requirements you have for the application you're trying to build. (Maybe if you are a litle more specific I can help you more, otherwise is a too generic question).

There's many ways of saving complex data. For example, and naming only a few ways to do it, you can use a small database like SQL Compact or SQLite, or you can just use a normal file to save information. A csv file, a xml file or a json file to store date. There are many ways to do it, it all depends on what you are trying to save. Is the amount of information big? Is the data somehow confidential? In every one of the refered examples you can chose the format that suits you better.



I am on mobile so bear with me.

This is a basic walk through of object serialization.

I think that there are pros and cons to either solution. You have to weigh them out and decide which is right for you, but I would go with a database. I would say my reasoning is quite arbitrary but this is exactly the purpose of a database. However...

If I were going to use object serialization and save to a file, and I wanted the single file approach, I would save everything in a big singleton. I'm not a expert though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.