private void LoadMessages() { /* * all tweets are stored in a central file. This will help with ordering by time of arrival * the default is the logged in users documents directory. All usrs are assumed to be logging on the same terminal * and using the same id... */ FileInfo fi = TweetRepository.GetFileRepository(); if (fi.Exists == false) { return; } TextFieldParser messageParser = new TextFieldParser(fi.FullName); messageParser.Delimiters = new string[] { "\t" }; messageParser.HasFieldsEnclosedInQuotes = false; while (messageParser.EndOfData == false) { string[] Messageparts = messageParser.ReadFields(); tweetyMessage newmessage = new tweetyMessage(); newmessage.user = Messageparts[0]; newmessage.messageText = Messageparts[1]; newmessage.messageDateTime = Convert.ToDateTime(Messageparts[2]); messages.Add(newmessage); } messageParser.Close(); }
public void writeMessage() { /* * if the save file does not exist then create it. otherwise write the contents of the message * to the file... * */ FileInfo fi = TweetRepository.GetFileRepository(); string MessageToWrite = String.Format("{0}\t{1}\t{2}\n", tm.user, tm.messageText, tm.messageDateTime); if (fi.Exists) { System.IO.File.AppendAllText(fi.FullName, MessageToWrite); } else { System.IO.File.WriteAllText(fi.FullName, MessageToWrite); } }