public List<Messages> getConferenceMessages() { try { string[] lines = File.ReadAllLines(@"C:\Users\liam\Documents\Conferences\" + this.name + ".txt"); messages = new List<Messages>(); // create individual messages by using a foreach loop. //foreach (string line in lines) for (int i = 0; i < lines.Length;i++ ) { string[] words = lines[i].Split(','); Messages newMessage = new Messages(words[0], Convert.ToDateTime(words[1]), words[2]); this.messages.Add(newMessage); this.messageCount++; } } catch(IOException IOexp) { } return this.messages; }
public void sendMessage(String messageText , string User,DateTime currentTime) { Messages newMessage = new Messages(User, currentTime, messageText); using (StreamWriter sw = File.AppendText(@"C:\Users\liam\Documents\Conferences\" + this.name + ".txt")) { sw.WriteLine(User+","+currentTime.ToString()+","+messageText); } }