Note that there are some explanatory texts on larger screens.

plurals
  1. POBest way to store data locally in .NET (C#)
    primarykey
    data
    text
    <p>I'm writing an application that takes user data and stores it locally for use later. The application will be started and stopped fairly often, and I'd like to make it save/load the data on application start/end.</p> <p>It'd be fairly straightforward if I used flat files, as the data doesn't really need to be secured (it'll only be stored on this PC). The options I believe are thus:</p> <ul> <li>Flat files</li> <li>XML</li> <li>SQL DB</li> </ul> <p>Flat files require a bit more effort to maintain (no built in classes like with XML), however I haven't used XML before, and SQL seems like overkill for this relatively easy task.</p> <p>Are there any other avenues worth exploring? If not, which of these is the best solution?</p> <hr> <p>Edit: To add a little more data to the problem, basically the only thing I'd like to store is a Dictionary that looks like this</p> <pre><code>Dictionary&lt;string, List&lt;Account&gt;&gt; </code></pre> <p>where Account is another custom type.</p> <p>Would I serialize the dict as the xmlroot, and then the Account type as attributes?</p> <hr> <p>Update 2:</p> <p>So it's possible to serialize a dictionary. What makes it complicated is that the value for this dict is a generic itself, which is a list of complex data structures of type Account. Each Account is fairly simple, it's just a bunch of properties.</p> <p>It is my understanding that the goal here is to try and end up with this:</p> <pre><code>&lt;Username1&gt; &lt;Account1&gt; &lt;Data1&gt;data1&lt;/Data1&gt; &lt;Data2&gt;data2&lt;/Data2&gt; &lt;/Account1&gt; &lt;/Username1&gt; &lt;Username2&gt; &lt;Account1&gt; &lt;Data1&gt;data1&lt;/Data1&gt; &lt;Data2&gt;data2&lt;/Data2&gt; &lt;/Account1&gt; &lt;Account2&gt; &lt;Data1&gt;data1&lt;/Data1&gt; &lt;Data2&gt;data2&lt;/Data2&gt; &lt;/Account2&gt; &lt;/Username2&gt; </code></pre> <p>As you can see the heirachy is </p> <ul> <li>Username (string of dict) > </li> <li>Account (each account in the List) > </li> <li>Account data (ie class properties). </li> </ul> <p>Obtaining this layout from a <code>Dictionary&lt;Username, List&lt;Account&gt;&gt;</code> is the tricky bit, and the essence of this question.</p> <p>There are plenty of 'how to' responses here on serialisation, which is my fault since I didn't make it clearer early on, but now I'm looking for a definite solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload