public void SaveToFile(int zone, int level) { string levelFilePath = LevelUtils.GetPathForLevelSave(zone, level); if (!Directory.Exists(Path.GetDirectoryName(levelFilePath))) { Directory.CreateDirectory(Path.GetDirectoryName(levelFilePath)); } XmlSerializer serializer = new XmlSerializer(typeof(LevelData)); FileStream stream = new FileStream(levelFilePath, FileMode.Create); serializer.Serialize(stream, this); stream.Close(); }