public void SaveFeeling(string path, FeelingInterface feeling) { // try to append new feeling to existing xml on device // if there is none create one try { TSC = TunneStructContainer.Load(path); TunneStruct[] temp = TSC.TunneStructArray; TSC.TunneStructArray = new TunneStruct[temp.Length + 1]; for (int i = 0; i < temp.Length; i++) { TSC.TunneStructArray[i] = temp[i]; } TSC.TunneStructArray[temp.Length] = (TunneStruct)feeling; TSC.Save(path); } catch (Exception e) { TunneStructContainer TSC = new TunneStructContainer(); List <FeelingInterface> feelingList = new List <FeelingInterface>(); feelingList.Add(feeling); TSC.Save(path, feelingList); // Debug.Log(e.ToString()); } }
/* * private string readData(string path) { * string data = null; * * try { * data = System.IO.File.ReadAllText(path); * } catch { * Debug.Log("ERROR : f*****g problems @ AccusationControllerScript"); * } * * return data; * } */ public void SaveData() { try { TSC = TunneStructContainer.Load(Application.persistentDataPath + "/feelings.xml"); } catch (Exception e) { TSC.Save(Application.persistentDataPath + "/feelings.xml", listOfFeelings); } }
private bool LoadData() { try { TSC = TunneStructContainer.Load(Application.persistentDataPath + "/feelings.xml"); return(true); } catch (Exception e) { return(false); } }