/// <summary> /// Writes the data to file. /// </summary> protected virtual void WriteDataToFile() { string data = Serialize(DATA); if (null != data) { try { using (StreamWriter sw = new StreamWriter(FILE_PATH)) { sw.Write(data); } } catch (Exception ex) { Logger.LogError("[JSONLocalStorage] Error in WriteDataToFile - " + ex.Message); } } }
/// <summary> /// Reads the data from file. /// </summary> protected virtual void ReadDataFromFile() { string data = null; try { if (File.Exists(FILE_PATH)) { Logger.Log("[JSONLocalStorage] Opening: " + FILE_PATH); using (StreamReader sr = new StreamReader(FILE_PATH)) { data = sr.ReadToEnd(); } } } catch (Exception ex) { Logger.LogError("[JSONLocalStorage] Error in ReadDataFromFile - " + ex.Message); } Deserialize(data); }