/// <summary> /// /// </summary> /// <returns></returns> public static XmlDataWrapper LoadData() { XmlDataWrapper data = new XmlDataWrapper(); TextReader reader = null; try { IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream file = storage.OpenFile(JournalFileName, FileMode.OpenOrCreate); reader = new StreamReader(file); XmlSerializer xs = new XmlSerializer(typeof(XmlDataWrapper)); data = (XmlDataWrapper)xs.Deserialize(reader); reader.Close(); file.Close(); } catch { return null; } finally { if (reader != null) reader.Dispose(); } return data; }
/// <summary> /// /// </summary> /// <param name="data"></param> public static void SaveData(XmlDataWrapper data) { TextWriter writer = null; try { IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream file = storage.OpenFile(JournalFileName, FileMode.Create); writer = new StreamWriter(file); XmlSerializer xs = new XmlSerializer(typeof(XmlDataWrapper)); xs.Serialize(writer, data); writer.Close(); file.Close(); } catch { } finally { if (writer != null) writer.Dispose(); } }
/// <summary> /// /// </summary> public void SaveData() { XmlDataWrapper wrapper = new XmlDataWrapper(this); StorageHelper.SaveData(wrapper); }