Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the code I use to save and load lists of objects from isolated storage. </p> <pre><code>public class IsoStoreHelper { private static IsolatedStorageFile _isoStore; public static IsolatedStorageFile IsoStore { get { return _isoStore ?? (_isoStore = IsolatedStorageFile.GetUserStoreForApplication()); } } public static void SaveList&lt;T&gt;(string folderName, string dataName, ObservableCollection&lt;T&gt; dataList) where T : class { if (!IsoStore.DirectoryExists(folderName)) { IsoStore.CreateDirectory(folderName); } string fileStreamName = string.Format("{0}\\{1}.dat", folderName, dataName); using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(fileStreamName, FileMode.Create, IsoStore)) { DataContractSerializer dcs = new DataContractSerializer(typeof(ObservableCollection&lt;T&gt;)); dcs.WriteObject(stream, dataList); } } public static ObservableCollection&lt;T&gt; LoadList&lt;T&gt;(string folderName, string dataName) where T : class { ObservableCollection&lt;T&gt; retval = new ObservableCollection&lt;T&gt;(); if (!IsoStore.DirectoryExists(folderName)) { IsoStore.CreateDirectory(folderName); } string fileStreamName = string.Format("{0}\\{1}.dat", folderName, dataName); using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(fileStreamName, FileMode.OpenOrCreate, IsoStore)) { if (stream.Length &gt; 0) { DataContractSerializer dcs = new DataContractSerializer(typeof(ObservableCollection&lt;T&gt;)); retval = dcs.ReadObject(stream) as ObservableCollection&lt;T&gt;; } } return retval; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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