public partial class MainForm : Form { public static ArrayList rooms = new ArrayList(); ... }
public void loadSettings() { string path = System.IO.Path.Combine(Environment.CurrentDirectory, "config/Rooms.cfg"); string currentLine; StreamReader read = new StreamReader(path); while ((currentLine = read.ReadLine()) != null) { String[] parts = currentLine.Split(';'); string name = parts[0]; string video = parts[1]; string isLogged = parts[2]; string notify = parts[3]; rooms.Add(new Room(name, video, isLogged, notify)); }
//In AddRoom.cs MainForm.rooms.Add(new Room(textBoxRoomName.Text)); MainForm.SaveAllRooms(); //In MainForm.cs public static void SaveAllRooms() { TextWriter tw = new StreamWriter(Environment.CurrentDirectory + "/config/Rooms.cfg"); foreach(Room room in rooms) { tw.WriteLine(room.name + ";" + room.videoFeed + ";" + room.isLogged + ";" + room.notify); } tw.Close(); populateListOfRooms(); //THIS IS WHERE MY LOGICAL ISSUE IS }