tags:

views:

146

answers:

4

I have an in memory DataTable in C#. I want to save a local copy of that on to my file system and retrive it . This C# datatable captures results from an excel formula and saves it. When the same excel file is opened again, I want to have the datatable loaded. This table is like a local cache that I want to reuse.

Is there any other structure that I can use apart from a data table for such a caching behavior?

How do I do that?

A: 

Sounds like you want XML Serialization.

http://devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=236

Rodrick Chapman
A: 

I would imagine a relational database like SQL Server would work quite well (especially since you are already storing the data in a tabular structure).

Andrew Hare
0 vote down check I do not want a database like SQL.To explain my case clearly ,I have a user defined function that an excel user uses. The formula does its calculations that writes to a data table or any other object on C# . I want this data table or object to be made available when an user opens the excel file again.
Sandy
A: 

If you aren't really worried about the format of the output, the easiest solution are the WriteXml and ReadXml methods on the DataSet.

DataSet data = new DataSet();

// Populate from excel

data.WriteXml(fileName, XmlWriteMode.WriteSchema); // Save to file
data.ReadXml(fileName); // Restore from file
Rory
A: 

I do not want a database like SQL.

To explain my case clearly ,

I have a user defined function that an excel user uses. The formula does its calculations that writes to a data table or any other object on C# . I want this data table or object to be made available when an user opens the excel file again.

Sandy
Please edit your question or leave a comment instead of adding an "answer".
Greg