I am trying to save data for my app I am using this code:
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create(Application.persistentDataPath + "/inventorySave.gd");
bf.Serialize(file, toSave);
file.Close();
I also tried this code:
StreamWriter sw = new StreamWriter(Application.persistentDataPath + "/inventorySave.txt");
sw.WriteLine(toSave);
print("wrote line" + toSave);
sw.Flush();
sw.Close();
But none of them seem to work (my unity crashes and I don’t get any errors in console). Saving is called inside a for loop, and I am trying to save string with less then 8 characters the code can be found here.