public void Save() { JsonTestClass.MusicalFile musicFile = new JsonTestClass.MusicalFile(); musicFile.numberNote = partition.Count; musicFile.musicalNote = new JsonTestClass.MusicalNote[partition.Count]; for (int i = 0; i < partition.Count; i++) { if (partition [i].NoteToPlay) { musicFile.musicalNote[i] = new JsonTestClass.MusicalNote(partition [i].NoteToPlay.getNoteName(), partition [i].NoteToPlay.Octave - 1, partition [i].nbFourth * 0.25f); } else { musicFile.musicalNote[i] = new JsonTestClass.MusicalNote(0, 10, partition [i].nbFourth * 0.25f); } } String ressourcePath = Path.Combine(Application.dataPath, "Resources"); // Get Path to game resources folder DirectoryInfo di = new DirectoryInfo(Path.Combine(ressourcePath, "StreamingAssets")); // Get Path to Streaming assets int numberFiles = CreateFiles.DirCount(di) / 2; String filePath = Path.Combine("StreamingAssets", "Comp" + numberFiles + ".json"); // Get Path to file in resources folder String realPath = Path.Combine(ressourcePath, filePath); // Get Real Path JsonTestClass.SaveJSONToFile(JsonTestClass.MapToJSON(musicFile), realPath); }